I've: ubuntu-9.10-desktop-amd64 + NetBeans6.7.1

  1. I simply downloaded "Commons HttpClient 3.1 (legacy)" from http://hc.apache.org/downloads.cgi .
  2. I produced new application with IDE NetBeans.
  3. I centered on Projects -> Libraries -> Add JAR/Folder and here added commons-httpclient-3.1.jar
  4. Right now, I'm able to write "import org.apache.commons.httpclient.*" This really is OK.
  5. But, basically consider adding any statement incorporated something similar to this:

    public static void main(String[] args) {
        HttpClient client = new HttpClient();
    }
    
  6. It's put together well.

  7. However when I run this project, I get 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***
    

What's wrong?

I attempted to download "HttpClient 4. (GA)". However the result was same. I attempted to make use of tutorial's example, however, a had just the group of the errors.

Yes, it will. What you're going through is simply a missing dependency. Java designers are utilized to gather their dependencies themselves, esp. if this involves logging frameworks. Download commons-logging and combine it with your classpath. Do too with all of other dependencies needed by httpclient.

You'll need the dependencies. Should you used maven, they'd fetch themselves. Because you aren't, you need to go download commons-logging (and possibly others) and toss them in.

If you do not desire to use Maven, then

- build and launch, look at missing dependencies
- identify vendor, fetch the jar to resolve dependencies
- rinse/repeat until you have all dependencies satisfied
- done

anyway you'll be never confident that all dependencies are 100% provided. Its usually around 150% or 99%, but never among

Let me update anybody coming here that all solutions, and particularly RocketSurgeon's, assisted me solve my problem within the same sense. I needed to download commons httpclient (legacy 3.1), logging and codec before my issues were resolved.

Also of note using Eclipse I needed to extract the .jar-files and import them into Buildpath using "add library". Didn't use only adding .zip-file.