[英].Jar file, created by netbeans doesn't open anymore on windows
For some reason, my application stopped working when I used "clean and build" at NetBeans and try to run it from dist folder. 出于某种原因,当我在NetBeans中使用“clean and build”并尝试从dist文件夹运行它时,我的应用程序停止工作。 Application used to open from the jar file, but now it only blinks, and even doesn't give any error messages.
应用程序用于从jar文件打开,但现在它只闪烁,甚至不会给出任何错误消息。 Application runs, if I test run it with F6 using NetBeans.
应用程序运行,如果我使用NetBeans测试使用F6运行它。 Jar file is created by NetBeans, so I guess the manifest should be okay.
Jar文件是由NetBeans创建的,所以我猜清单应该没问题。
Executing the jar in the terminal gives this exception trace: 在终端中执行jar会产生以下异常跟踪:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:155)
at tbs.ImageLoader.loadImage(ImageLoader.java:11)
at tbs.Flag.<init>(Flag.java:21)
at tbs.Model.<init>(Model.java:58)
at tbs.GameView.<init>(GameView.java:33)
at tbs.GUI.<init>(GUI.java:36)
at tbs.Main.main(Main.java:6)
So it looks like you had something like this here: 所以看起来你有这样的东西:
public Image loadImage(String name) {
return new ImageIcon(getClass().getResource(name));
}
... and the getResource()
method returned null
, which caused the ImageIcon
constructor to throw the Exception. ...并且
getResource()
方法返回null
,这导致ImageIcon
构造函数抛出异常。
In line 21 of Flag.java you used "images/flagNeutral.png"
as the image string, but your jar file contains images/flagneutral.png
(inside the tbs
directory). 在Flag.java的第21行中,您使用
"images/flagNeutral.png"
作为图像字符串,但您的jar文件包含images/flagneutral.png
(在tbs
目录中)。 See the difference? 看到不同?
If it worked on your local system outside of the jar, you are using a case-insensitive file system there. 如果它在jar之外的本地系统上运行,那么您在那里使用不区分大小写的文件系统。 (Windows or Mac?) In the jar, as well as over HTTP and on "real" file systems, the URLs are case sensitive, which means you have to name the resource precisely as the file is named.
(Windows或Mac?)在jar,以及HTTP和“真实”文件系统上,URL都区分大小写,这意味着您必须在命名文件时精确命名资源。
And yeah, normally you should have at least tried your program yourself, and posted the stack trace as well as the relevant code lines. 是的,通常你应该至少自己尝试过你的程序,并发布堆栈跟踪以及相关的代码行。
Typical error when you don't define the main class before clean and run. 在清理和运行之前未定义主类时的典型错误。
Click right on the project -> properties ->run section ->define the main class. 单击项目右键 - >属性 - >运行部分 - >定义主类。
java -jar tbs.jar
and see the response. java -jar tbs.jar
一样运行它并查看响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.