gpt4 book ai didi

java - 在 Geany 中导入外部 jar

转载 作者:行者123 更新时间:2023-11-29 09:30:49 25 4
gpt4 key购买 nike

我在导入 jar 文件并在 Geany IDE 中运行时遇到问题.这就是我所做的:我下载了Jsoup .提取它并将 org 文件放在我的项目目录中。然后将其导入到我的源代码中:

    import org.jsoup.*;// why this does not import all
/*
instead I need to import everything manually
import org.jsoup.Jsoup;
import org.jsoup.helper.Validate;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
*/

public class Crawler {

public static void main (String args[]) {
String html = "<html><head><title>First parse</title></head>"
+ "<body><p>Parsed HTML into a doc.</p></body></html>";
Document doc = Jsoup.parse(html);
}
}

当我尝试在 Geany 中编译它时,出现错误:

Crawler.java:7: cannot find symbol
symbol : class Document
symbol : class Document
symbol : class Document

我做错了什么,我该如何解决?

最佳答案

下载 jar 文件并将 external jar 放在某个 \lib 目录中,并将其添加到项目的类路径中。作为一种好的做法,不要使用通配符导入 org.jsoup.* 使用 org.jsoup.Document

关于java - 在 Geany 中导入外部 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12448752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com