[標(biāo)題]:[原]命令行運(yùn)行class文件出現(xiàn)NoClassDefFoundError
[時(shí)間]:2012-02-14
[摘要]:Java命令運(yùn)行程序時(shí)出現(xiàn)java.lang.NoClassDefFoundError: org/apache/http/HttpEntity。
[關(guān)鍵字]: Java、package、Jar、運(yùn)行、error、class-path、庫(kù)、HttpClient
[文章編號(hào)]:暫無(wú)
[環(huán)境]: JDK 7.0
[作者]: Wintys (wintys@gmail.com)
[錯(cuò)誤]:
運(yùn)行命令行:
[原因&解決]:
被運(yùn)行的程序編譯正常通過(guò),運(yùn)行卻出現(xiàn)了NoClassDefFoundError,不知道是哪里出錯(cuò)了。找了半天,發(fā)現(xiàn)編譯程序的命令行有問(wèn)題,-cp參數(shù)應(yīng)放到類(lèi)名前面來(lái):
[時(shí)間]:2012-02-14
[摘要]:Java命令運(yùn)行程序時(shí)出現(xiàn)java.lang.NoClassDefFoundError: org/apache/http/HttpEntity。
[關(guān)鍵字]: Java、package、Jar、運(yùn)行、error、class-path、庫(kù)、HttpClient
[文章編號(hào)]:暫無(wú)
[環(huán)境]: JDK 7.0
[作者]: Wintys (wintys@gmail.com)
[錯(cuò)誤]:
運(yùn)行命令行:
java NetLogin -cp .;commons-codec-1.4.jar;commons-logging-1.1.1.jar;httpclient-4.1.3.jar;httpclient-cache-4.1.3.jar;httpcore-4.1.4.jar;httpmime-4.1.3.jar
出現(xiàn)如下錯(cuò)誤:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpEntity
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpEntity
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
[原因&解決]:
被運(yùn)行的程序編譯正常通過(guò),運(yùn)行卻出現(xiàn)了NoClassDefFoundError,不知道是哪里出錯(cuò)了。找了半天,發(fā)現(xiàn)編譯程序的命令行有問(wèn)題,-cp參數(shù)應(yīng)放到類(lèi)名前面來(lái):
java -cp .;commons-codec-1.4.jar;commons-logging-1.1.1.jar;httpclient-4.1.3.jar;httpclient-cache-4.1.3.jar;httpcore-4.1.4.jar;httpmime-4.1.3.jar NetLogin
原創(chuàng)作品,轉(zhuǎn)載請(qǐng)務(wù)必保持原文完整性并注明出處。
作者:wintys (wintys@gmail.com)
博客:http://www.aygfsteel.com/wintys
作者:wintys (wintys@gmail.com)
博客:http://www.aygfsteel.com/wintys