简体   繁体   English

如何将库导入 NetBeans 中的 Java 项目?

[英]How can I import a library to a Java project in NetBeans?

I needed a class that could create polygons with Double or Float numbers, instead of int numbers.我需要一个类来创建带有 Double 或 Float 数字的多边形,而不是 int 数字。 Well, I found it here , and here is the Jar file download .嗯,我在这里找到这里是 Jar 文件下载 I extracted the Jar and added it to the libraries in NetBeans;我提取了 Jar 并将其添加到 NetBeans 中的库中; but now, I don't know how to import the package to my project.但是现在,我不知道如何将包导入到我的项目中。 If I type "import org.apache.batik.ext.awt.geom;", it says that the package does not exist.如果我输入“import org.apache.batik.ext.awt.geom;”,它说这个包不存在。 How can I import that package to my project?如何将该包导入到我的项目中? Thanks!谢谢!

It's very easy.. you just expand the project tree in netbeans and right click to Libraries folder which is in the project.. and select the Add Jar/Folder option and choose your downloaded jar file.. nad click to open.. after that you can able to import these libraries..这很容易......你只需在netbeans中展开项目树并右键单击项目中的Libraries文件夹......然后选择添加Jar/Folder选项并选择你下载的jar文件......然后点击打开......之后您可以导入这些库..

预览

It's not enough to define the library in Netbeans.在 Netbeans 中定义库是不够的。 You need to add the library to your project.您需要将库添加到您的项目中。 Then your import will work.然后您的导入将起作用。

After defining the library in Netbeans (under Tools - Libraries ) you can add it as follows to the project: Right-click Libraries in your project tree, select Add Library... and then select your newly defined library.在 Netbeans 中定义库后(在Tools - Libraries 下),您可以按如下方式将其添加到项目中:右键单击项目树中的Libraries ,选择Add Library... ,然后选择新定义的库。

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

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