Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to import "org.apache.http.client.HttpClient" in Eclipse?

Tags:

java

apache

I have tried httpcore.jar by following the step here, but when I write import org.apache.http.client.HttpClient, it still can't be found. The jar is already downloaded by Maven.

Is httpcore the right lib for importing org.apache.http.client.HttpClient? or org.apache.http.client.HttpClient is just used for Android developing?

Another question, what is the difference between org.apache.http.client.HttpClient and org.apache.commons.httpclient.HttpClient?

like image 801
user1447011 Avatar asked Jul 29 '12 14:07

user1447011


People also ask

How do I change the HttpClient to Java built in HTTP in eclipse?

I had exactly the same issue with eclipse 2020-12. In Preferences->Git I changed " Http Client " to " Java built-in HTTP " and the issue is resolved.

What is Apache HttpClient?

HttpClient is a HTTP/1.1 compliant HTTP agent implementation based on HttpCore. It also provides reusable components for client-side authentication, HTTP state management, and HTTP connection management.

What is the use of HttpClient in Java?

An HttpClient can be used to send requests and retrieve their responses. An HttpClient is created through a builder . The builder can be used to configure per-client state, like: the preferred protocol version ( HTTP/1.1 or HTTP/2 ), whether to follow redirects, a proxy, an authenticator, etc.


1 Answers

First of all: http://hc.apache.org/httpclient-3.x/

The Commons HttpClient project is now end of life, and is no longer being developed. It has been replaced by the Apache HttpComponents project in its HttpClient and HttpCore modules, which offer better performance and more flexibility.

So, you need to use HttpClient (http://hc.apache.org/httpcomponents-client-ga/index.html), not Commons HttpClient (take a look in the name of the packages that you said).

Yes, org.apache.http.client.HttpClient is the right package.

Did you have certain that Maven obtained the .jar and it is in your classpath?

like image 56
davidbuzatto Avatar answered Nov 09 '22 07:11

davidbuzatto