【发布时间】:2014-12-19 06:01:24
【问题描述】:
我有点困惑。我有一个我正在开发的 JavaFX 程序(爱好),它在我的 Mac 上构建和运行得很好。 (我有最新的 Oracle Java 7)。当我运行在 Mac(在最新的 NetBeans 中)上构建的 jar 文件时,在我的 32 位 Linux 系统(也使用最新的 Oracle 版本)上,它给了我以下错误:
java.lang.reflect.InvocationTargetException
file:/home/me/aFolder/SomeOne/Saved/Something.jar!/Something/mainWindow.fxml
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2186)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
at Something.Something.start(Something.java:33)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
at java.lang.Thread.run(Unknown Source)
Something.java:33 的行是我调用的地方
AnchorPane mainWindowPane =
(AnchorPane)FXMLLoader.load(UdoMail.class.getResource("mainWindow.fxml"));
所以,我很困惑从哪里开始。这是在我的 Mac 上构建的 jar 文件,移动到 32 位 Linux(运行最新的 32 位 Oracle Java),然后运行。
相当奇怪的是,如果我在 32 位 Linux 上构建它,然后在我的 Mac 上运行 Linux 构建的 jar 文件,我会(实际上)在 Mac 上得到相同的错误。
如果我在构建时在同一个平台上运行,那么一切正常。 (也就是说,如果我获取代码并在 Linux 上构建它,它可以在 Linux 上完美运行,但不能在 Mac 上运行。)
由于我似乎无法在 Linux 上为 Mac 构建的 jar 文件运行调试器(反之亦然),所以我有点不知道从哪里开始寻找。我已经确保我正在使用 File.separator 并寻找其他特定于操作系统的东西,但我想找出 FXMLLoader.java 中的这些行是什么(在源代码中),以了解它为什么会出现问题。注释掉大部分代码后,似乎导致 barf 的行是一个简单的 File 实例化:
File myFile = new File(userDirectoryString);
我使用了很多文件和目录,这一行是我的代码中对文件或目录使用的第一次调用。我已经验证了字符串“userDirectoryString”,它是正确的。
有什么想法吗?
【问题讨论】:
标签: java cross-platform javafx-2