Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 可执行的.jar文件没有';跑不动_Java_Javafx - Fatal编程技术网

Java 可执行的.jar文件没有';跑不动

Java 可执行的.jar文件没有';跑不动,java,javafx,Java,Javafx,我的.jar文件有问题。 当我在IDEA中运行它时,它工作得很好,但当我在jar文件中构建它时,应用程序忽略双击。 我尝试在cmd行中运行它,并收到下一个异常: Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun

我的.jar文件有问题。 当我在IDEA中运行它时,它工作得很好,但当我在jar文件中构建它时,应用程序忽略双击。 我尝试在cmd行中运行它,并收到下一个异常:

  Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
        at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/__it/Desktop/Ilab%20API%20UI%20+%20CODE%20v%202.0/ApplicationExampleForClients%20V_1.0%20(CODE)/out/artifacts/ApplicationExampleForClients_V_1_0_jar/ApplicationExampleForClients%20V_1.0.jar!/Interface.fxml

        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2543)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
        at Main.start(Main.java:27)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
        ... 1 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[56,1]
Message: Stream closed
        at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
        at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2513)
        ... 17 more
Exception running application Main
我导入到project one库,当它仅在java 1.8中工作时,jar应用程序已经工作,但当我更新所有java版本的库时,导入到project并运行它,收到了这个堆栈跟踪

[编辑] lib的变化:

 private static void LoadPlatformPacketTypesFromAssembly() {

    Reflections reflections = new Reflections("com.intenselab.jlabframework");

    Set < Class < ? extends Object>> allProtocolMessages =reflections.getTypesAnnotatedWith(IntenseLabPacket.class);

    allProtocolMessages.forEach(aClass -> {
        crc32.reset();
        crc32.update(aClass.getSimpleName().getBytes());
        messageTypesMap.put(aClass, (int) crc32.getValue());

    });

}
private static void LoadPlatformPacketTypesFromAssembly(){
反射=新反射(“com.intenselab.jlabframework”);
Set>allProtocolMessages=reflections.getTypesAnnotatedWith(IntenseLabPacket.Class);
allProtocolMessages.forEach(aClass->{
crc32.reset();
更新(aClass.getSimpleName().getBytes());
messageTypesMap.put(aClass,(int)crc32.getValue());
});
}

Was没有
“com.intenselab.jlabframework”

在构建/导出应用程序时,请确保将所有必需的jar文件添加到导出的jar文件中。有一个关于执行此操作的人的描述:

它不起作用,因为您无法从文件系统访问
JAR
中的文件(这就是文件API所做的)

文件:/C:/Users/\uuuu it/Desktop/Ilab%20API%20UI%20+%20CODE%20v%202.0/ApplicationExampleForClients%20v\u1.0%20(CODE)/out/artifacts/ApplicationExampleForClients\u1\u0\ujar/ApplicationExampleForClients%20v\u1.0.jar/Interface.fxml

ApplicationExampleforClient%20V\u 1.0.jar
表示您希望访问JAR中的文件,但这将无法工作,因为您的文件系统无法直接访问它。您应该使用资源从JAR访问特定于项目的材料

所以你最终会得到类似的结果


InputStream in=SomeClass.class.getResourceAsStream(“Interface.fxml”)

谢谢您的回答,但是:我所做的是:我用按钮witch创建了新的fxml文件my Interface.fxml,它可以工作。WhhHyyyyyyyyyyyy?????因为IDEA(或Ecliplse或NB)不构建JAR来运行应用程序。它使用的普通文件很可能位于
目录中,这些文件没有打包到任何东西中,并且存在于文件系统中。是的,但是当添加带有button witch stars my Interface.fxml的新fxml文件时,它可以与jar一起工作,因为自动生成的代码是使用资源而不是像您这样的文件生成的。