Java Netbeans JAR 构建和运行
我的 Netbeans 项目中有几个包。
其中一个包有一个 main 方法,该方法被设置为项目的 main 方法。
我使用 clean 并构建,并且 Jar 已成功创建,但是当我尝试运行 .jar 文件时,应用程序无法正确运行。
我正在运行的 Main.class 具有创建项目中其他包中其他类的实例的按钮,但是当我从命令行运行它时,单击按钮通常会在控制台中打印 null 或异常。如何设置 Netbeans 以便 .jar 成功运行?
I have several packages in my Netbeans project.
One of these packages has a main method, which is set as the main method for the project.
I use clean and build and the Jar is created successfully, however when I try and run the .jar file The application does not run correctly.
The Main.class that I am running has buttons that create instances of other classes which are in other packages within the project, however when I run it from the command line clicking the buttons usually prints null or an exception out the the console. How would I set up Netbeans so that the .jar runs successfully?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“我如何设置 Netbeans 以便 .jar 成功运行?”
您不知道。一旦 jar 和 s 构建完成,它就是或者应该是独立的。 NetBeans 并没有什么问题吧。
您没有指定 NPE 发生的位置,但您的应用程序可能使用特定的文件结构,并且您尝试运行 jar,但没有或维护文件位于相同的位置或具有相同的名称在 NB 内与他们合作时。
"How would I set up Netbeans so that the .jar runs successfully?"
You don't. Once the jar and s built, it is, or should be, independent. NetBeans is not what's wrong with it.
You didn't specify where your NPEs are happening, but it's likely your application uses a certain file-structure, and that you're attempting to run the jar while not having or maintaining the files in the same positions or with the same names as when working with them within NB.