开发者

Package does not exist

开发者 https://www.devze.com 2022-12-23 16:15 出处:网络
I get an \"Build failed\" error with error output when I开发者_如何学Python try to build my project in Eclipse:

I get an "Build failed" error with error output when I开发者_如何学Python 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?


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


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


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


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 ;)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号