我的.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
我仅将一个库导入Java 1.8,但仍运行jar应用程序,但是当我为所有Java版本更新库,导入到项目并运行它时,都收到了此堆栈跟踪。
>[编辑] 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());
});
}
没有"com.intenselab.jlabframework"
答案 0 :(得分:1)
由于无法从文件系统访问#include <string.h>
#include <stdio.h>
int main () {
char str[80] = "11111:";
const char s[2] = ":";
char *token;
int a = 0;
int b = 0;
/* get the first token */
token = strtok(str, s);
a = atoi(token);
printf( " %s\n", a );
/* get the second token */
token = strtok(NULL, s); // Here is seg.fault
if (token != NULL)
b = atoi(token);
else
b = 0;
printf( " %s\n", b );
return(0);
}
中的文件(文件API会执行此操作),因此无法正常工作
文件:/ C:/用户/ __ it /桌面/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
JAR
表示您要访问JAR内的文件,并且该文件将无法工作,因为您的文件系统无法直接访问它。您应该使用资源来从JAR访问项目特定的材料。
https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html#class
所以您最终会得到类似于
的内容 ApplicationExampleForClients%20V_1.0.jar!
答案 1 :(得分:0)
在构建/导出应用程序时,请确保将所有必需的jar文件添加到导出的jar文件中。关于谁可以执行此操作的说明:Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project