Apache HttpClient抛出NoClassDefFoundError [英] Apache HttpClient throws a NoClassDefFoundError

查看:224
本文介绍了Apache HttpClient抛出NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:ubuntu-9.10-desktop-amd64 + NetBeans6.7.1

I have: ubuntu-9.10-desktop-amd64 + NetBeans6.7.1


  1. 我刚刚下载了Commons HttpClient 3.1(legacy)来自 http://hc.apache.org/downloads.cgi

  2. 我使用IDE NetBeans创建了新的应用程序。

  3. 我专注于项目 - >库 - >添加JAR /文件夹,这里添加了commons-httpclient- 3.1.jar

  4. 到现在为止,我可以写import org.apache.commons.httpclient。*;这没关系。

  5. 但是,如果我尝试添加任何语句,包括以下内容:

  1. I just downloaded "Commons HttpClient 3.1 (legacy)" from http://hc.apache.org/downloads.cgi .
  2. I created new application with IDE NetBeans.
  3. I focused on Projects -> Libraries -> Add JAR/Folder and here added commons-httpclient-3.1.jar
  4. By now, I can write "import org.apache.commons.httpclient.*;" This is OK.
  5. But, if I try to add any statement included something like this:

public static void main(String[] args) {
    HttpClient client = new HttpClient();
}


  • 汇编得很好。

  • It is compiled well.

    但是当我运行这个项目时,我收到以下错误:

    But when I run this project, I receive the following errors:

    ***Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:66)
        at SimplestAppl.Main.main(Main.java:22)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
        ... 2 more
    Java Result: 1***
    


  • 出了什么问题?

    我试图下载HttpClient 4.0(GA)。但结果是一样的。

    I tried to download "HttpClient 4.0 (GA)". But the result was same.

    推荐答案

    您所遇到的只是一个缺失的依赖。 Java开发人员习惯于自己收集依赖项,尤其是。当涉及到日志框架时。
    下载commons-logging并将其添加到类路径中。与httpclient所需的所有其他依赖项一样。

    What you are experiencing is just a missing dependency. Java developers are used to gather their dependencies themselves, esp. when it comes to logging frameworks. Download commons-logging and add it to your classpath. Do as well with all other dependencies required by httpclient.

    这篇关于Apache HttpClient抛出NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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