使用 Netbeans 导出 JAR
如何使用Netbeans将java项目导出到JAR?我找不到像 Eclipse 那样的选项。
How to export java project to JAR with Netbeans ? I cannot find options like in Eclipse.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要启用选项
Project Properties ->构建->包装->编译后构建JAR
(但默认情况下启用)
You need to enable the option
Project Properties -> Build -> Packaging -> Build JAR after compiling
(but this is enabled by default)
您的意思是编译到JAR吗? NetBeans 会自动执行此操作,只需执行“清理并构建”并查看项目的“dist”子目录即可。将有一个带有“lib”文件夹的 JAR,其中包含所需的库。这些 JAR + lib 足以运行应用程序。
如果在项目属性中禁用“保存时编译”,则不再需要执行“清理和构建”,在大多数情况下只需“构建”就足够了。如果您只想更改一些代码并重建 JAR,这将节省时间。但是,请注意,NetBeans 有时无法正确处理依赖关系和二进制兼容性,这将导致错误的 JAR 抛出“没有此类方法”或其他模糊的异常。因此,如果自上次完全重建以来您进行了很多更改,甚至远程不确定即使某些类没有重新编译它仍然可以工作,那么您仍然必须执行完整的“清理和构建”以获得完美的结果工作罐子。
Do you mean compile it to JAR? NetBeans does that automatically, just do "clean and build" and look in the "dist" subdirectory of your project. There will be the JAR with "lib" folder containing the required libraries. These JAR + lib are enough to run the application.
If you disable "Compile on save" in the project properties, then it is no longer necessary to do "clean and build", simply "build" will suffice in most cases. This will save time if you want to change just a bit of the code and rebuild the JAR. However, note that NetBeans sometimes fails to handle dependencies and binary compatibility properly, which will lead to a faulty JAR throwing "no such method" or other obscure exceptions. Therefore, if you made a lot of changes since the last full rebuild and even remotely unsure that it will still work even if some classes aren't recompiled, then you must still do a full "clean and build" in order to get a perfectly working JAR.
它默认执行此操作,您只需查看项目的
/dist
文件夹。It does this by default, you just need to look into the project's
/dist
folder.