eclipse 获取 java.lang.ClassNotFoundException: org.jsoup.Jsoup

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4235855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:22:20  来源:igfitidea点击:

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

javaeclipseclassnotfoundexceptionbuildpathjsoup

提问by gk1

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.

我在谷歌应用引擎上运行我的应用程序。我所拥有的只是一个尝试使用 Jsoup 的简单 servlet。但是,当我运行应用程序时,我得到 java.lang.ClassNotFoundException: org.jsoup.Jsoup。

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

我正在使用 Eclipse,所以我在 Java Build Path -> Libraries 中添加了 jsoup jar 文件

回答by BalusC

You need to put the Jsoup JAR file in the /WEB-INF/libfolder of the webapp. That folder is covered by webapp's default classpath. Also, Eclipse will automagically put all libraries in /WEB-INF/libfolder 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.

您需要将 Jsoup JAR 文件放在/WEB-INF/libwebapp的文件夹中。该文件夹由 webapp 的默认类路径覆盖。此外,Eclipse 会自动将所有库放在/WEB-INF/lib项目构建路径中的文件夹中,您不需要手动执行此操作。当然,我假设该项目是作为Dynamic Web Project创建的。

回答by josh-cain

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

添加 .jar 的另一种方法是右键单击您的项目,然后选择Properties -> Java Build Path,单击Libraries选项卡,然后单击Add External JARs...这将允许您浏览到 .jar 的路径您要添加的文件。

回答by pbojinov

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

还要确保您的import org.jsoup.Jsoup;导入是在所有应用程序导入之后,例如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.

在那些其他导入之前先导入 JSOUP 会导致我在某一时刻部署应用程序时出错。

回答by Kakopappa

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

我现在在我的 Android 项目上遇到了同样的错误。要在 Android 上修复此问题,您需要创建一个 lib 文件夹并将 .jar 文件放在那里