Derk
Derk

Reputation: 1087

Package does not exist

I get an "Build failed" error with error output when I try to build my project in Eclipse:

[javac] ......\src\example\servlet\ScrapingServlet.java:10: package org.apache.http.client does not exist [javac] import org.apache.http.client.HttpClient;

But the Eclipse editor does not give any error. I added the jars to the project with Project > properties > add external JARS... and all the JARS are showed in the project explorer. What am I doing wrong?

Upvotes: 0

Views: 25886

Answers (5)

Joshua Pinter
Joshua Pinter

Reputation: 47621

I ran into a similar error in Android Studio.

I was added a module dependency of a libs/httpcomponents directory I created that contained a number of jar files, including commons-httpclient.jar but that wasn't working for some reason.

Once I moved commons-httpclient.jar to just the libs/ directory and updated the module dependency by adding that file explicitly, the build worked fine.

Weird science.

Upvotes: 0

nicolas_eo
nicolas_eo

Reputation: 1

Try to added the jars to be copied in the build.xml, like this:

  <!-- copy JavaMail support jars build directory -->
<mkdir dir="${basedir}/jlib/javamail"/>  <!-- make sure 'from' dir exists to avoid warnings -->
<copy todir="${build.lib}" failonerror="false" verbose="false">
    <!-- ok if this file does not exist -->
    <fileset dir="${basedir}/jlib/javamail">
       <include name="activation.jar"/> <!-- not needed for JDK 6+ -->
       <include name="mail.jar"/>
    </fileset>
</copy>

this works for me ;)

Upvotes: 0

Derk
Derk

Reputation: 1087

Solved my problem. I had to add the filenames of the JARS to the build.xml file.

Upvotes: 1

Amber Shah
Amber Shah

Reputation: 772

If you have just added the jars, sometimes you need to do a Clean and then build for it to take effect.

Upvotes: 1

Teja Kantamneni
Teja Kantamneni

Reputation: 17492

Check whether you have added commons-httpclient.jar or not.

Upvotes: 0

Related Questions