Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org.apache packages can't be resolved in Eclipse

The following

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

can't be resolved. I downloaded the Apache Http packages and imported them via the external jars option, but it still won't get resolved. In Android it seems to work, guessing its in the SDK, but here I'm not doing Android. Did I get the wrong packages?

I believe this is the link:

Apache

like image 486
Fasih Awan Avatar asked Aug 29 '12 20:08

Fasih Awan


People also ask

How do I resolve an error in eclipse?

The Quick Fix dialog can also be displayed by right clicking on the error item in the Problems view and selecting the Quick Fix menu item.

Can not be resolved to a type java?

This means that your project isn't setup to include the JUnit libraries when it compiles; JUnit is not included in the Java runtime libraries (JRE System Library) so you have to add it to the build path.


2 Answers

It sounds OK:

1) The .jar file in question should be something like "httpcore-4.0.1.jar". 
   Please confirm the name.

2) Adding this to "External Libraries" is absolutely the correct thing to do.

3) For compiling in the Eclipse IDE, you must:

   a) Select your project

   b) Select "Build Path" > "Add External Libraries"

4) For running in the Eclipse IDE, you must

   a) Select "Run" > "Run configurations".  
      Choose your (Java Application?) configuration.

   b) Select "Classpath" > "Add External Jar"

5) For running outside of the Eclipse IDE, you must make sure the .jar 
   file is present and your -cp (Classpath) argument is set correctly.
like image 160
paulsm4 Avatar answered Sep 28 '22 05:09

paulsm4


After dragging the jars into my project I was having the same issue.

Right-click on the jar and selecting Build-path -> Add-to-Build-Path worked for me.

like image 40
anthonybell Avatar answered Sep 28 '22 06:09

anthonybell