httpClient?

fuyou001 2008-12-03 04:40:13
我在http://hc.apache.org/downloads.cgi上下载了一个HttpClient 4.0-beta1

我把httpClient class已经加到程序里,
我用最简单的例子(httpClient自带的例子),测试了下
package com.fuou;

import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;


/**
* This example demonstrates the use of the {@link ResponseHandler} to simplify
* the process of processing the HTTP response and releasing associated resources.
*/
public class ClientWithResponseHandler {

public final static void main(String[] args) throws Exception {

HttpClient httpclient = new DefaultHttpClient();
//HttpResponse response = httpclient.execute(httpget);

// HttpGet httpget = new HttpGet("http://www.google.com/");

// System.out.println("executing request " + httpget.getURI());

// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
// String responseBody = httpclient.execute(httpget, responseHandler);
// System.out.println(responseBody);

System.out.println("----------------------------------------");
}

}


我已改成上面的程序,但还报 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/params/HttpParams错误,
我在httpClient里也确实 没找到Httpparams类文件,这是怎么回事!要到哪去找这个类,还是我下错了?

...全文
146 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zealVampire 2008-12-05
  • 打赏
  • 举报
回复
HttpClient的jar包依赖httpcomponents-core-4.0-beta3 把这个也下了..
libing821126 2008-12-04
  • 打赏
  • 举报
回复
你需要下载http://hc.apache.org/downloads.cgi下面的
Binary 下的4.0-beta1.zip 和 Binary with dependencies 的 4.0-beta1.zip,
然后把里面的Jar包导入项目,就OK了。
fuyou001 2008-12-03
  • 打赏
  • 举报
回复
没人吗

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧