无法实例化类型HttpClient [英] Cannot instantiate the type HttpClient

查看:572
本文介绍了无法实例化类型HttpClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将.jars添加到我的库,我也可以在JAR中实例化其他类。是什么赋予了?我试图清理项目等。



这是一个编译器时间错误。我不会让我实例化它。



我正在导入正确的库,而不是太阳版本,并使用默认的引用,由他们的教程

  HttpClient client = new HttpClient(); ($,
$ / pre $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ a a a a a a a a a a a a a a a a a a a a a a href =http://hc.apache.org/downloads.cgi =nofollow noreferrer> here )

解决方案

HttpClient 是4.x中的一个接口,对于实例使用 DefaultHttpClient

  HttpClient httpclient = new DefaultHttpClient(); 


I have added the .jars to my library and I can also instantiate other classes in the JAR. What gives? I've tried to clean the project etc.

It's a compiler-time error. Eclipse won't let me instantiate it.

I'm importing the correct library, not the sun version, and using the default contructor, specified by their tutorial

HttpClient client = new HttpClient();

(Eclipse, mac, Apache HTTP, "HttpClient 4.0.1 (GA)" downloaded from here)

解决方案

HttpClient is an interface in 4.x, use DefaultHttpClient for instances.

HttpClient httpclient = new DefaultHttpClient();

这篇关于无法实例化类型HttpClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆