I use a code that imports the following package:
import org.apache.commons.httpclient.*;
I use eclipse. I went to http://hc.apache.org/downloads.cgi & I downloaded the Jar files, I added them to my project. Still eclipse making an error for this.
Exception in thread "main" java.lang.Error: Unresolved compilation problems: HttpClient cannot be resolved to a type
What is the problem?
If you are using the latest (4.x) version of these modules, they have been refactored a lot.
For example, the package name is now org.apache.http.client.
Old sample code will have to be modified.
Look at the Javadocs and the Quickstart for the new project.
The (discouraged) alternative would be to get the old (3.x) version.
I would recommend using Maven for managing your 3rd party dependencies. It takes care of jar files & all related dependencies.
The maven dependency for httpclient is:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.1</version>
<scope>compile</scope>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With