10

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

2
  • 2
    Sometimes after importing external libraries, I have to refresh dependencies or close and open the project to get the eclipse errors to go away. Commented Aug 29, 2012 at 22:21
  • Good point. I often do an Eclipse "Project, Clean" for precisely that reason. Commented Aug 30, 2012 at 2:06

3 Answers 3

13

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:

    • Select your project

    • Select "Build Path" > "Add External Libraries"

  4. For running in the Eclipse IDE, you must

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

    • 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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks paulsm4. Google removed the support for Apache HTTP Client, according to this:developer.android.com/about/versions/marshmallow/… You yourself have to download a copy of httpcore-4.0.1.jar from java2s.com/Code/Jar/h/Downloadhttpcore401jar.htm Import it into your libs folder. That will solve the problem. Proguard exception: -dontwarn org.apache.http.** -dontwarn com.android.volley.toolbox.**
1

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.

Comments

0

If you first added those JARs to an Android project, but now want to use them in another (non-Android) project, make sure you've imported the JARs into this other project. In Eclipse, each project maintains its own build classpath settings, so importing JARs into one project does not automatically make them available to other projects.

2 Comments

That wasn't what I meant. I was just saying in the case of Android all these packages are available so I didn't have to import their respective jars
@E-Riz What to do if I want to add a jar so that it can be available to all the project, do I have to add it in plugin folder - C:\eclipse-jee-luna-R-win32\eclipse\plugins ??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.