NetBeans 和可执行 JAR

发布于 2024-12-02 09:41:47 字数 650 浏览 0 评论 0原文

这里是 NetBeans 开发新手。当我第一次创建项目并开始编译时,我注意到 NetBeans 在我的项目根目录下自动创建了一个 dist/ 目录,并在该目录中创建了一个可执行 JAR。

我现在已经开发了几周,并向我的项目添加了许多资源文件,包括系统日志文件、嵌入式 SQLite 数据库和几个属性文件。我的程序(Swing 应用程序)需要在运行时读取/写入这些文件才能正常运行。

今天早上我刚刚注意到我的 dist/ 目录中的可执行 JAR 已经有几周了,编译我的项目并没有更新它。我想知道这是否是因为现在有所有这些新资源文件,而 NetBeans 不知道如何/在哪里将它们打包为自动创建的可执行 JAR。

这是否意味着我必须自己调整 build.xml ?或者是否有一个 NetBeans 对话框可以让我指定将所有内容打包到哪里?如果 NetBeans 应该自动执行此操作,那么它停止为我创建 JAR 的原因可能是什么?我可以做什么来再次强制执行此功能?

我进入项目属性>>打包并确保JAR文件目录仍然是dist/MyProgram.jar并且复选框编译后构建JAR是仍在检查,所以显然有其他东西破坏了构建或扰乱了 NB。

感谢您的任何提示!

New to NetBeans dev here. When I first created my project and began compiling, I noticed that NetBeans had automatically created a dist/ directory under my project root and was creating an Executable JAR in that directory.

I've now been developing for several weeks, and added many resource files to my project, including a system log file, an embedded SQLite database, and several properties files. These are files that my program (a Swing app) needs to read/write from at runtime in order to function correctly.

I just noticed this morning that the Executable JAR in my dist/ directory is several weeks old, and that compiling my project doesn't update it. I am wondering if that's because there are now all these new resource files and NetBeans doesn't know how/where to package them for the automatically-created Executable JAR.

Does this mean that I'll have to tweak the build.xml myself? Or is there a NetBeans dialog I can get to where I can specify where to pacakge everything? And if NetBeans should be doing this automatically, what could be the reason that it stopped creating the JAR for me, and what can I do to force this functionality again?

I went into Project Properties >> Packaging and made sure that the JAR file directory was still dist/MyProgram.jar and that the checkbox Build JAR after compiling was still checked, so obviously something else is either breaking the build or messing with NB.

Thanks for any tips!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疾风者 2024-12-09 09:41:47

如果启用“保存时编译”,则仅当您执行“清理和构建”时才会生成 .jar 文件(启用“保存时编译”时仅“构建”不可用)

If "Compile on Save" is enabled, then your .jar file will only be generated when you do a "Clean & Build" (Just "Build" is not available when "Compile on Save" is enabled)

梦里寻她 2024-12-09 09:41:47

您需要在 netbeans 中进行清理和构建来更新 /dist 目录中的文件。

我使用 Netbeans 7.0,这个解决方案适合我。

You need to Clean and Build within netbeans to update the file within your /dist directory.

I use Netbeans 7.0 and this solution works for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文