简体   繁体   English

在Eclipse中使用Jsoup时出错

[英]Error when using Jsoup in Eclipse

I downloaded the .jar Jsoup file from jsoup.org/download. 我从jsoup.org/download下载了.jar Jsoup文件。 I then ran eclipse and imported the .jar files into a java project. 然后,我运行eclipse并将.jar文件导入到Java项目中。 However, I keep getting an error when I type 但是,输入时我总是收到错误消息

import org.jsoup.nodes.*; 导入org.jsoup.nodes。*;

I want to use the Document class in that file. 我想在该文件中使用Document类。

I made sure the syntax was correct and everything, but the error won't go away. 我确保语法正确无误,但错误不会消失。 Anyone know what the problem could be? 有人知道可能是什么问题吗?

You need to add the JAR file to project's build path. 您需要将JAR文件添加到项目的构建路径。 Drop the JAR in the project's root folder or some /lib folder, rightclick the JAR file and then choose Build Path > Add to Build Path . 将JAR拖放到项目的根文件夹或某个/lib文件夹中,右键单击JAR文件,然后选择Build Path> Add to Build Path


Unrelated to the concrete problem, using wildcard imports is not the best practice. 具体问题无关 ,使用通配符导入不是最佳实践。 Rather specify the imports separately, or just let Eclipse autocomplete it by entering Ctrl+Space after typing Document in the code. 可以单独指定导入,也可以在代码中输入Document后通过输入Ctrl + Space来让Eclipse自动完成导入。

右键单击Eclipse中的项目>属性> Java构建路径>添加jar>从您之前导入的项目中选择jar>确定

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM