[英]NullPointerException when trying to load an FXML file - only when run as Jar file
I'm developing a small application to learn JavaFX with. 我正在开发一个小应用程序来学习JavaFX。 I've run into an issue where when I run my app with an IDE (Eclipse) it works perfectly.
我遇到了一个问题,当我用IDE(Eclipse)运行我的应用程序时,它运行得很好。 However when I export the project to a runnable Jar file, and try to run the jar file, the window I want to pop up doesn't.
但是,当我将项目导出到可运行的Jar文件,并尝试运行jar文件时,我想要弹出的窗口不会。 I've exported it as every type of the three options eclipse allows.
我已经将它导出为eclipse允许的三种选项中的每一种。
I ran it through the command line to get the stacktrace: 我通过命令行运行它来获取stacktrace:
http://pastebin.com/tfkJFnEZ http://pastebin.com/tfkJFnEZ
The rest of the app works great, just this one window. 应用程序的其余部分工作得很好,只有这一个窗口。 What is puzzling to me (as a beginner) is why it will run in Eclipse but not after exportation.
让我感到困惑的是(作为初学者)是为什么它会在Eclipse中运行而不是在导出后运行。 I'm not sure what is changing in the way I want to open the file, so I'm not sure where to look for my error.
我不确定我想要打开文件的方式有什么变化,所以我不确定在哪里查找我的错误。
If there is anything else I need to provide to assist just let me know, I appreciate any advice anyone can give. 如果我需要提供任何其他信息以帮助我告诉我,我感谢任何人都能给予的建议。
So what I found was that when I tried to set data into the TableView (shown as an error at line 39 in the stacktrace) it was throwing the error. 所以我发现当我尝试将数据设置到TableView(在堆栈跟踪中第39行显示为错误)时,它就抛出了错误。 It turns outthe TableView was set as static.
事实证明,TableView被设置为静态。 I honestly am not sure why I set it up this way, but as soon as I removed the "static" in front of it the windows pops open and works.
老实说,我不知道为什么我这样设置它,但是一旦我删除它前面的“静态”,窗口就会弹出并打开。 I feel a little silly that it was something so simple.
我觉得有点傻,这很简单。
However, I'm still confused as to why a static TableView that works in Eclipse fail to work on a Jar file. 但是,我仍然感到困惑的是为什么在Eclipse中工作的静态TableView无法在Jar文件上工作。 Anyone have any ideas?
有人有想法么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.