关于java httpclient编程的问题
importjava.io.FileOutputStream;importjava.io.InputStream;importjava.io.OutputStream;i...
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
public class spider {
public static void main(String[] args) {
HttpClient hp = new HttpClient();
}
}
很简单的程序但是编译出这样的结果:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient
at s.sb.main(sb.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
已经引入了所需的三个jar包,是要设置环境变量吗 展开
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
public class spider {
public static void main(String[] args) {
HttpClient hp = new HttpClient();
}
}
很简单的程序但是编译出这样的结果:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpClient
at s.sb.main(sb.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpClient
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 1 more
已经引入了所需的三个jar包,是要设置环境变量吗 展开
展开全部
请查查是否没有正确地导入jar包. 在您的webroot目录下webinf下放置一个lib文件夹,三个包加入其中,右键lib --build path.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询