Error in Java code for Eclipse: the import Org.apache cannot be resolved

Source: Internet
Author: User

In Eclipse, toss Java code.

Take the previous code from Android and use it.

The result appears the import Org.apache cannot be resolved error:

"Resolution Process"

1. Here:

For help, Eclispe development cannot import Org.apache package

And

The import Org.apache cannot be resolved

All said, let go:

Add External Jar ' s Configure build path---Libraries, project--Build path--

But the pit daddy is, did not say, here the

Org.apache

is which jar package belongs to.

2. Now that I can't find

Org.apache

So, given that I'm here, it's all:

?
1234567891011121314151617181920212223 import org.apache.http.HttpEntity;import org.apache.http.HttpResponse;import org.apache.http.HttpStatus;import org.apache.http.NameValuePair;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.CookieStore;//import org.apache.http.client.HttpClient;import org.apache.http.client.entity.UrlEncodedFormEntity;import org.apache.http.client.methods.HttpGet;import org.apache.http.client.methods.HttpPost;import org.apache.http.client.methods.HttpUriRequest;import org.apache.http.cookie.Cookie;import org.apache.http.impl.client.BasicCookieStore;import org.apache.http.impl.client.DefaultHttpClient;//import org.apache.http.impl.cookie.BasicClientCookie;import org.apache.http.params.HttpParams;import org.apache.http.protocol.BasicHttpContext;import org.apache.http.protocol.HttpContext;import org.apache.http.client.params.ClientPNames;import org.apache.http.client.protocol.ClientContext;import org.apache.http.util.EntityUtils;

That is, all:

Org.apache.http

Then go and find org.apache.http first.

3. Reference:

Excuse me, who has org.apache.http this bag?

Suddenly thought, looks like this:

Org.apache.http

is the corresponding Android inside, not the standard Java library.

4. So, go to what others say, find this library in Apache's official website.

Search:

Download Org.apache.http

And find http://hc.apache.org/downloads.cgi, go download

HttpClient 4.2.5.zip

After decompression, get:

Httpcomponents-client-4.2.5-bin\httpcomponents-client-4.2.5\lib

Here are a lot of jars:

Try it first:

Then all the org.apache.http are normal:

Summary

Org.apache, not a library in standard Java. So in eclipse, it can't be recognized automatically.

Org.apache includes a bunch of related libraries, and here's the org.apache.http, so:

You need to find the corresponding org.apache.http-related jar package and add it to the current project.

1. Where to find Org.apache.http

To the Apache official website:

http://hc.apache.org/downloads.cgi

To download:

HttpClient 4.2.5.zip

Then, after downloading, unzip, can be in:

Httpcomponents-client-4.2.5-bin\httpcomponents-client-4.2.5\lib

See the respective JAR packages in the following:

Commons-codec-1.6.jar

Commons-logging-1.1.1.jar

Fluent-hc-4.2.5.jar

Httpclient-4.2.5.jar

Httpclient-cache-4.2.5.jar

Httpcore-4.2.4.jar

Httpmime-4.2.5.jar

2. How to add a jar to the current project

See:

Tutorial How to add a library (jar package) to eclipse

http://www.crifan.com/java_eclipse_the_import_org_apache_cannot_be_resolved/

Error in Java code for Eclipse: the import Org.apache cannot be resolved

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.