简体   繁体   English

如何在Netbeans中导入库?

[英]How to import libraries in Netbeans?

I am working on a Java program, where it will print the stored string in backwards. 我正在使用Java程序,它将向后打印存储的字符串。 And I would like to use the ArrayUtils method. 而且我想使用ArrayUtils方法。
So, in order to do that, I have to import org.apache.commons.lang.ArrayUtils; 因此,为了做到这一点,我必须导入org.apache.commons.lang.ArrayUtils;。 (commons-lang-2.6.jar), which I dont have. (commons-lang-2.6.jar),我没有。 And I would like to download it and add it to the library. 我想下载它并将其添加到库中。
Once I am in the commons.apache.org page and look for commons-lang-2.6.jar, there are actually 2 sections : 一旦进入commons.apache.org页面并查找commons-lang-2.6.jar,实际上就有2个部分:
Binaries, and Source. 二进制文件和源代码。
Which one should I download and how do I add the library? 我应该下载哪一个,以及如何添加该库?

the next link contains a jar file which you can import to your project (into libraries): http://www.java2s.com/Code/JarDownload/apache-commons/apache-commons-lang.jar.zip 下一个链接包含一个jar文件,您可以将其导入到您的项目中(到库中): http : //www.java2s.com/Code/JarDownload/apache-commons/apache-commons-lang.jar.zip

basically, the binaries files are compiled code and that is what you want. 基本上,二进制文件是编译后的代码,这就是您想要的。

"how do I add the library?" “如何添加库?”

To add a new Library to NetBeans, 要将新的库添加到NetBeans,

  • do the following ( after downloading and extracting the library you need) 执行以下操作(下载并解压缩所需的库之后
    1. If you click Tools -> Library a popup will come up. 如果单击Tools -> Library将弹出一个弹出窗口。
    2. There you can add a new library. 您可以在此处添加新库。 Click on New Library and give a name the new Library. 单击New Library并命名新库。
    3. Import a library from the ClassPath tab - click Add Jar/Folder , locate and select. 从“ ClassPath选项卡导入库-单击“ Add Jar/Folder ,找到并选择。
    4. If you want to can also add the javadoc from the JavaDoc tab. 如果需要,还可以从JavaDoc选项卡添加javadoc。 You would add the file from the library file you downloaded, called javadoc . 您可以从下载的库文件javadoc添加文件。 This will allow for the javadocs to be seen while editing your code. 这样可以在编辑代码时看到javadocs。
    5. Also you can add the sources file form the Sources tab. 您也可以从“ Sources选项卡添加源文件。 Import the file named sources 导入名为sources的文件
    6. Then right-click on the Libraries folder icon in your project and Add Library 然后右键单击项目中的Libraries文件夹图标,然后Add Library
  • Another option is just add the .jar . 另一种选择是仅添加.jar
    1. Right-click on the Libraries folder icon in your project and click Add Jar 右键单击项目中的Libraries文件夹图标,然后单击“ Add Jar
    2. Locate the .jar file and add it. 找到.jar文件并添加它。

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

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