Getting a java.lang.ClassNotFoundException: org.jsoup.Jsoup

时光怂恿深爱的人放手 提交于 2019-12-30 07:07:11

问题


I am running my app on google app engine. All I have is a simple servlet that is trying to use Jsoup. However when I run the application I get java.lang.ClassNotFoundException: org.jsoup.Jsoup.

I am using Eclipse so I added the jsoup jar file in the Java Build Path -> Libraries


回答1:


You need to put the Jsoup JAR file in the /WEB-INF/lib folder of the webapp. That folder is covered by webapp's default classpath. Also, Eclipse will automagically put all libraries in /WEB-INF/lib folder in the buildpath of the project, you shouldn't need to do that manually. Of course I assume that the project is been created as Dynamic Web Project.




回答2:


Another way to add the .jar is to right click on your project, and choose Properties -> Java Build Path, click the Libraries tab, then click Add External JARs... This will allow you to browse to the path of the .jar file you wish to add.




回答3:


Also make sure your import org.jsoup.Jsoup; imports are after all the application imports such as import com.google.gwt.core.client.GWT;

Having the JSOUP imports before those other imports caused errors for deploying an application at one point for me.




回答4:


I had the same error now on my Android project. To Fix this on Android, you need to create a lib folder and put the .jar file there



来源:https://stackoverflow.com/questions/4235855/getting-a-java-lang-classnotfoundexception-org-jsoup-jsoup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!