简体   繁体   English

如何在Netbeans项目中添加.jar文件并指定相对路径

[英]How to add a .jar file in a Netbeans project specifying a relative path

I'm trying to add ojdbc and another .jar file into my project specifying the relative path such that, if I gave the project to a friend of mine, he would be able to import that project with all necessary .jar files already included (and so he doesn't have to pick these files, but the project .zip file is "ready-to-use"). 我正在尝试将ojdbc和另一个.jar文件添加到我的项目中,并指定相对路径,这样,如果我将该项目交给我的一个朋友,他将能够使用已经包含所有必需的.jar文件导入该项目(因此他不必选择这些文件,但项目.zip文件是“随时可以使用的”)。

Now, as the following image shows: 现在,如下图所示:

添加jar文件

I right click on my project's Libraries entry and choose the necessary .jar file. 我右键单击项目的Libraries条目,然后选择必要的.jar文件。 But when I try to specify a relative path, Netbeans deny it and so I could not be able to give this project (exported as a .zip file using Netbeans' export "function"), as the following image shows: 但是,当我尝试指定相对路径时,Netbeans拒绝了它,因此我无法给出这个项目(使用Netbeans的导出“函数”导出为.zip文件),如下图所示:

没有选择

  • What am I doing wrong? 我究竟做错了什么?
  • Is this the right way to "include" these .jar files to the project and then export it and give it to a friend of mine? 这是将这些.jar文件“包含”到项目中,然后将其导出并提供给我的朋友的正确方法吗?

Note that my .zip project which I import with Netbeans and my .jar file are in the same directory (Desktop): 请注意,我使用Netbeans导入的.zip项目和.jar文件位于同一目录(桌面)中:

在此处输入图片说明

Solved : 解决

  1. Add your .jar files as shown in the 1st and 2nd images; 如第一张和第二张图片所示添加您的.jar文件;
  2. Right click on project; 右键单击项目;
  3. Properties; 属性;
  4. Libraries; 图书馆;
  5. Click on that .jar file you added; 点击您添加的.jar文件;
  6. Where is written "Libraries Folder" click Browse and click next. 在其中写有“库文件夹”的位置,单击浏览,然后单击下一步。

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

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