简体   繁体   中英

java.lang.NoClassDefFoundError

I got "java.lang.NoClassDefFoundError" Exception when I want to use a certain jar file.

Exception in thread "main" java.lang.NoClassDefFoundError: .
org/apache/http/client/ClientProtocolException
    at ?uk.org.taverna.server.client.connection.ConnectionFactory.getConnection(ConnectionFactory.java:63)
    at uk.org.taverna.server.client.Server.<init>(Server.java:99)
    at uk.org.taverna.server.client.Server.<init>(Server.java:126)
    at uk.org.taverna.server.client.Server.connect(Server.java:293)
    at uk.org.taverna.server.usage.ServerUsage.Usage(ServerUsage.java:24)
    at Test.main(Test.java:23)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

I import this jar file to jar library, when I call the method in that jar file I got this Exception. By the way, This jar file be wrote by myself, and I can run it correctly. I have no idea how to solve this problem, I am quite new in java.

Thanks in advance.

Sandy

You need also at least HttpClient jar-library. You can get it at Apache Commons web-site.

Jar libraries may and often refer to another jar libraries. In your case library you are using refers to HttpClient library from Apache Commons framework. You need to add this library to your project.

You should but all the jar files you use in you application in the libs folder in your application directory . so if you use the apachecommons jar file copy and paste the jar file to the libs folder in your application .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM