Java 共享一个 Netbeans 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22919220/
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-13 19:00:34  来源:igfitidea点击:

Sharing a Netbeans project

javanetbeansshared-libraries

提问by PurpleVermont

I have a java project that I developed in Netbeans. Because I was the only developer and it's a simple project (one source file, but it needs several specialty libraries) I didn't use source control.

我有一个在 Netbeans 中开发的 Java 项目。因为我是唯一的开发人员并且它是一个简单的项目(一个源文件,但它需要几个专业库)我没有使用源代码控制。

I'm no longer going to be working on the project, and want to hand it over to someone else in case they need to make changes to it in the future. I don't think it will be sufficient to just zip up the project folder and send it to her, as the project points to libraries located elsewhere (multiple locations) on my computer. Is there a way to direct Netbeans to create a shareable copy of the project that would include copies of all the libraries, with the required pointers? (There are copies of the libraries in dist/lib, but I'm pretty sure that's not where Java looks for them when building the project.)

我将不再参与该项目,并希望将其移交给其他人,以防他们将来需要对其进行更改。我认为仅压缩项目文件夹并将其发送给她是不够的,因为该项目指向位于我计算机上其他位置(多个位置)的库。有没有办法指导 Netbeans 创建一个可共享的项目副本,其中包含所有库的副本,以及所需的指针?(在 dist/lib 中有库的副本,但我很确定 Java 在构建项目时不会在那里查找它们。)

Would Export Project -> to ZIPfrom the Filemenu do what I need here?

Export Project -> to ZIPFile菜单中做什么,我需要在这里?

采纳答案by zlinks

If you want to export the project so that it will be reopened from a NetBeans IDE:

如果要导出项目以便从 NetBeans IDE 重新打开它:

  • Right click your project and choose to create a new folder. Name it lib and press OK. You will be able to see the folder if you go to the Filestab.

  • Then put (copy) your libraries there.

  • Then go back to projects tab and right click the libraries node. Choose add JAR/Folder and point to where your jar you want to use is (inside the lib folder). Select the file and also make sure that you choose the Reference as: Relative Pathoption. Click open.

  • You will now be able to see your library if you expand the libraries node of your project.

  • Select your project and then choose Export project to ZIPfrom the file menu.

  • 右键单击您的项目并选择创建一个新文件夹。将其命名为 lib,然后按 OK。如果转到Files选项卡,您将能够看到该文件夹。

  • 然后将(复制)您的库放在那里。

  • 然后返回到项目选项卡并右键单击库节点。选择添加 JAR/文件夹并指向您要使用的 jar 所在的位置(在 lib 文件夹内)。选择文件并确保您选择参考为:相对路径选项。点击打开。

  • 如果您展开项目的库节点,您现在将能够看到您的库。

  • 选择您的项目,然后Export project to ZIP从文件菜单中进行选择。

Thats it.

就是这样。

If you extract the created zip file you will see the lib folder with all the JAR files in it. Also if you go to the nbprojectand open the file project.propertiesyou will see some lines like file.reference.dom4j-1.6.1.jar=lib\\dom4j-1.6.1.jar. I believe this is how Netbeans knows where to find the libraries you need.

如果您解压创建的 zip 文件,您将看到包含所有 JAR 文件的 lib 文件夹。此外,如果您转到nbproject并打开文件,project.properties您会看到一些类似file.reference.dom4j-1.6.1.jar=lib\\dom4j-1.6.1.jar. 我相信这就是 Netbeans 知道在哪里可以找到您需要的库的方式。

If you want to migrate to Eclipse: http://www.coderanch.com/t/458555/vc/Export-Netbeans-Eclipse

如果你想迁移到 Eclipse:http: //www.coderanch.com/t/458555/vc/Export-Netbeans-Eclipse

If you want to be general then you should build your project with Mavenor Ant. Every modern IDE (Eclipse,NetBeans,InteliJ) can understand these building tools.

如果您想通用,那么您应该使用Maven或构建您的项目Ant。每个现代 IDE(Eclipse、NetBeans、InteliJ)都可以理解这些构建工具。

Hope it helps you.

希望对你有帮助。