c***a 发帖数: 364 | 1 因为HttpClient4.0没有.commons了,所以使用HttpClient3.0.1。
其实就是run一个例子:
http://hc.apache.org/httpclient-3.x/tutorial.html
编译都通过了,我也能够在HttpClient的包中看到HttpClient这个class,但是运行的
时候就是找不到,报错NoClassDefFoundError。
写了一个很小的测试程序:
package test;
import org.apache.commons.httpclient.*;
public class test {
public static void main(String args[]){
HttpClient client = new HttpClient();
}
}
错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/
commons/logging/LogFactory
at org.apache.commons.httpclient.HttpClient.(HttpClient.java
at HttpClientTutorial.HttpClientTutorial.main(HttpClientTutorial.
java:23) |
g*****g 发帖数: 34805 | 2 Make sure commons logging jar is in classpath.
【在 c***a 的大作中提到】 : 因为HttpClient4.0没有.commons了,所以使用HttpClient3.0.1。 : 其实就是run一个例子: : http://hc.apache.org/httpclient-3.x/tutorial.html : 编译都通过了,我也能够在HttpClient的包中看到HttpClient这个class,但是运行的 : 时候就是找不到,报错NoClassDefFoundError。 : 写了一个很小的测试程序: : package test; : import org.apache.commons.httpclient.*; : public class test { : public static void main(String args[]){
|
c******n 发帖数: 4965 | 3 noclassdeffound does NOT mean that you don't have .class in path
ClassNotFound means that.
this one actually means that the ctor of the class failed. most likely
some setup issues caused the ctor to fail
this is a very common misconception, u can google that
【在 c***a 的大作中提到】 : 因为HttpClient4.0没有.commons了,所以使用HttpClient3.0.1。 : 其实就是run一个例子: : http://hc.apache.org/httpclient-3.x/tutorial.html : 编译都通过了,我也能够在HttpClient的包中看到HttpClient这个class,但是运行的 : 时候就是找不到,报错NoClassDefFoundError。 : 写了一个很小的测试程序: : package test; : import org.apache.commons.httpclient.*; : public class test { : public static void main(String args[]){
|
c******n 发帖数: 4965 | 4 btw
it's almost impossible to develop code without some dependency
management system (ivy/maven)
if you use these,
ant clean
maven clean
would most likely remove doubts about class path issues
【在 c***a 的大作中提到】 : 因为HttpClient4.0没有.commons了,所以使用HttpClient3.0.1。 : 其实就是run一个例子: : http://hc.apache.org/httpclient-3.x/tutorial.html : 编译都通过了,我也能够在HttpClient的包中看到HttpClient这个class,但是运行的 : 时候就是找不到,报错NoClassDefFoundError。 : 写了一个很小的测试程序: : package test; : import org.apache.commons.httpclient.*; : public class test { : public static void main(String args[]){
|