views:

282

answers:

3

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)

+2  A: 

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

HttpClient httpclient = new DefaultHttpClient();
PartlyCloudy
A: 
HttpClient client = new DefaultHttpClient();

They haven't documented this anywhere on the website, but I've imported the source, and the javadoc, and this was the example in the Javadoc for the HttpClient class.

Aymon Fournier
Be aware of breaking changes in such projects, always check for the correct version when reading docs, tutorials etc.Good API design is hard, and avoiding breaking changes even harder, unfortunately.
PartlyCloudy
I think I'll stick with the legacy one, since all the tutorials are 3.x
Aymon Fournier
http://hc.apache.org/httpcomponents-client/tutorial/html/
PartlyCloudy
A: 

You find the javadoc to the version you downloaded here. You linked in your post to version 3.x.

Examples you find here

stacker