简体   繁体   English

Java Netbeans JAR构建和运行

[英]Java Netbeans JAR building and running

I have several packages in my Netbeans project. 我的Netbeans项目中有几个软件包。

One of these packages has a main method, which is set as the main method for the project. 这些软件包之一具有main方法,该方法被设置为项目的main方法。

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. 我使用clean和build并成功创建了Jar,但是当我尝试运行.jar文件时,应用程序无法正常运行。

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. 我正在运行的Main.class具有创建项目中其他包中其他类的实例的按钮,但是当我从命令行运行它时,单击按钮通常会在控制台中输出null或异常。 How would I set up Netbeans so that the .jar runs successfully? 我将如何设置Netbeans以便.jar成功运行?

"How would I set up Netbeans so that the .jar runs successfully?" “我将如何设置Netbeans以便.jar成功运行?”

You don't. 你不知道 Once the jar and s built, it is, or should be, independent. 一旦jar和s建立起来,它便是或应该是独立的。 NetBeans is not what's wrong with it. NetBeans并不是问题所在。

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. 您没有指定NPE发生的位置,但是您的应用程序可能使用了特定的文件结构,并且您试图运行jar,而没有将文件保留在相同的位置或使用相同的名称在NB中与他们合作时。

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

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