随笔 - 117  文章 - 72  trackbacks - 0

声明:原创作品(标有[原]字样)转载时请注明出处,谢谢。

常用链接

常用设置
常用软件
常用命令
 

订阅

订阅

留言簿(7)

随笔分类(130)

随笔档案(123)

搜索

  •  

积分与排名

  • 积分 - 152522
  • 排名 - 390

最新评论

[标题]:[原]命令行运行class文件出现NoClassDefFoundError
[时间]:2012-02-14
[摘要]:Java命令运行程序时出现java.lang.NoClassDefFoundError: org/apache/http/HttpEntity。
[关键字]: Java、package、Jar、运行、error、class-path、库、HttpClient
[文章编号]:暂无
[环境]: JDK 7.0
[作者]: Wintys  (wintys@gmail.com)

[错误]:
    运行命令行:
    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
    出现如下错误:
    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

[原因&解决]:
    被运行的程序编译正常通过,运行却出现了NoClassDefFoundError,不知道是哪里出错了。找了半天,发现编译程序的命令行有问题,-cp参数应放到类名前面来:
    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

原创作品,转载请务必保持原文完整性并注明出处。
作者:wintys (wintys@gmail.com)
博客:http://www.blogjava.net/wintys
posted on 2012-02-14 16:03 天堂露珠 阅读(2105) 评论(0)  编辑  收藏 所属分类: Error

只有注册用户登录后才能发表评论。


网站导航: