Java 将第三方库与 netbeans 一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18161212/
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
Using third party libraries with netbeans
提问by yasar
I am very new to Java. I am trying to use jsoupin a small project. I couldn't set up my netbeans to use it.
我对Java很陌生。我想在一个小项目中使用jsoup。我无法设置我的 netbeans 来使用它。
I have opened a folder for third party libraries in C:\Users\muhammed\jarlibraries
and I have put jsoup-1.7.2.jar
in it. Then I right clicked on libraries and selected add jar folder. Now my project looks like this;
我已经为第三方库打开了一个文件夹,C:\Users\muhammed\jarlibraries
并将jsoup-1.7.2.jar
其放入。然后我右键单击库并选择添加 jar 文件夹。现在我的项目是这样的;
As you can see from the image above, netbeans cannot resolve Jsoup when I say Fix Imports. Am I doing something wrong here? How would this process work?
从上图可以看出,当我说 Fix Imports 时,netbeans 无法解析 Jsoup。我在这里做错了吗?这个过程将如何运作?
采纳答案by Dennis Kriechel
Why do you placed your libary into a package? Thats not how you do that. Do this instead:
你为什么把你的库放在一个包里?那不是你这样做的方式。改为这样做:
- Go to project properties by right clicking on project.
- Then click on Libraries tab, You will see Compile, Run, Compile Tests, Run Tests tabs.
- Click on Compile tab (the first tab, selected by default)
- Click on Add JAR/Folder button at right
- Then browse and select the jar file(not the folder) you want to include. Included jar file will show on the following box of Compile tab.
- Click on OK button.
- Finished.
- 通过右键单击项目转到项目属性。
- 然后单击库选项卡,您将看到编译、运行、编译测试、运行测试选项卡。
- 单击编译选项卡(第一个选项卡,默认选中)
- 单击右侧的添加 JAR/文件夹按钮
- 然后浏览并选择要包含的 jar 文件(不是文件夹)。包含的 jar 文件将显示在“编译”选项卡的以下框中。
- 单击确定按钮。
- 完成的。
Than it will be added to you project and classpath.
它将被添加到您的项目和类路径中。
You imported a complete folder into the project, but you only have a single jar file.
您将一个完整的文件夹导入到项目中,但您只有一个 jar 文件。