似乎受到影响的代码是以下类。
package VennDiagram;
import java.io.File;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
//merged
public class View extends Application{
public static Stage primaryStage;
public static Scene promptWindow;
public static Scene refactor;
public static Scene scene;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception{
// System.out.printf("root = %s\n",getclass().getResource("/views/View.fxml"));
primaryStage = stage;
Parent root = FXMLLoader.load(getclass().getResource("View.fxml"));
Parent root2 = FXMLLoader.load(getclass().getResource("openingPage.fxml"));
//scene = new Scene(root,900,650);
scene = new Scene(root);
promptWindow = new Scene(root2,1020,580);
promptWindow.getStylesheets().add(getclass().getResource("openingPage.css").toExternalForm());
scene.getStylesheets().add(getclass().getResource("application.css").toExternalForm());
primaryStage.setOnCloseRequest(event ->{
quitProgramAlert.display("Confirm Exit","Are you sure you want to exit?");
if(!quitProgramAlert.closepressed) {
event.consume();
}
});
primaryStage.setMinHeight(600);
primaryStage.setMinWidth(750);
primaryStage.setTitle("VennDiagram Creator");
primaryStage.setScene(promptWindow);
primaryStage.setResizable(false);
//primaryStage.getIcons().add(0,new Image(getclass().getResourceAsStream("/images/icon.png")));
primaryStage.show();
}
}
运行时出现的错误是...
Exception in Application start method
Exception in thread "main" java.lang.reflect.invocationTargetException
at java.base/jdk.internal.reflect.NativeMethodaccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodaccessorImpl.invoke(NativeMethodaccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodaccessorImpl.invoke(DelegatingMethodaccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/openxml4j/exceptions/InvalidFormatException
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3138)
at java.base/java.lang.Class.getconstructor0(Class.java:3343)
at java.base/java.lang.Class.newInstance(Class.java:572)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:936)
at javafx.fxml/javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:980)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:227)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:752)
at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2722)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2552)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3113)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3106)
at VennDiagram.View.start(View.java:36)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.accessController.doPrivileged(accessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Caused by: java.lang.ClassnotFoundException: org.apache.poi.openxml4j.exceptions.InvalidFormatException
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:436)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 27 more
我使用以下标志运行jar文件...
java -jar --module-path "MY_PATH_TO_MODULES" --add-modules javafx.controls,javafx.fxml,javafx.graphics JAR_NAME.jar
其他信息:某个apache库无法与应用正确构建,这可能是最后一次错误的原因。但是我无法弄清楚前几个。
我所有的FXML文件都与调用它们的类放在同一个程序包中。 View在36处的错误与以下行有关...
Parent root = FXMLLoader.load(getclass().getResource("View.fxml"));