"主" java.lang.NoClassDefFoundError:org / apache / http / HttpEntity [英] "main" java.lang.NoClassDefFoundError: org/apache/http/HttpEntity

查看:3029
本文介绍了"主" java.lang.NoClassDefFoundError:org / apache / http / HttpEntity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中使用apache http库。我在我的项目中导入了libreries http://imgur.com/WvwqcDS

I'm trying to use the apache http library in my project. I imported the libreries in my project http://imgur.com/WvwqcDS

当我运行程序时,我收到此错误:

When I run my program, I get this error:

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


推荐答案

ClassLoader找不到org.apache.http.HttpEntity,它应该在httpcore-4.3.jar里面。将jar作为存档打开并验证它是否包含org / apache / http / HttpEntity.class。如果是,则问题出在启动配置中。在Eclipse中,转到Run> Run Configurations ...并找到主类的Java Application概要文件(根据屏幕截图,它应该是包含Launcher项目中main方法的类)。在Classpath选项卡下,您应该看到列出的库jar。

The ClassLoader can't find org.apache.http.HttpEntity, which should be inside "httpcore-4.3.jar". Open the jar as an archive and verify that it contains org/apache/http/HttpEntity.class. If it does, the issue is in your launch configuration. In Eclipse, go to Run > Run Configurations... and find the Java Application profile for your main class (which should be the class containing the main method in "Launcher" project, based on the screenshot). Under the Classpath tab, you should see your library jars listed.

如果没有,请返回导航窗格中的Launcher项目,右键单击并选择Properties ,转到构建路径,删除您的罐子,按确定,然后返回并再次添加它们(以确保eclipse元数据是新鲜的)。此外,在订购和导出选项卡下,最好还是检查所有罐子,这样如果您将Launcher作为另一个项目的依赖项包含在内,那么这些罐子是可传递的。

If not, go back to your "Launcher" project in the Navigation pane, right-click and select Properties, go to "Build Path", remove your jars, press OK, then go back in and add them again (to guarantee the eclipse meta-data is fresh). Also, under the "Order and Export" tab, it's a good idea to check off all jars so that if you include Launcher as a dependency for another project, the jars are transitively included.

这篇关于"主" java.lang.NoClassDefFoundError:org / apache / http / HttpEntity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆