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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 22:55:39  来源:igfitidea点击:

Using third party libraries with netbeans

javanetbeans

提问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\jarlibrariesand I have put jsoup-1.7.2.jarin 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 文件夹。现在我的项目是这样的;

enter image description here

在此处输入图片说明

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:

你为什么把你的库放在一个包里?那不是你这样做的方式。改为这样做:

  1. Go to project properties by right clicking on project.
  2. Then click on Libraries tab, You will see Compile, Run, Compile Tests, Run Tests tabs.
  3. Click on Compile tab (the first tab, selected by default)
  4. Click on Add JAR/Folder button at right
  5. 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.
  6. Click on OK button.
  7. Finished.
  1. 通过右键单击项目转到项目属性。
  2. 然后单击库选项卡,您将看到编译、运行、编译测试、运行测试选项卡。
  3. 单击编译选项卡(第一个选项卡,默认选中)
  4. 单击右侧的添加 JAR/文件夹按钮
  5. 然后浏览并选择要包含的 jar 文件(不是文件夹)。包含的 jar 文件将显示在“编译”选项卡的以下框中。
  6. 单击确定按钮。
  7. 完成的。

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 文件。