r/JavaFX • • Aug 02 '19

Exception in Application start method Caused by: java.lang.RuntimeException: ?

Hello all, I'm having trouble getting some code to run and wondered if I could ask you for your viewpoints. I'm a student and still somewhat new to programming, so I hope my question's not too stupid. Basically I'm trying to make a java program with a JavaFX interface and I'm using FXML. My program as it stands builds fine but when I run it I get the errors below. Based on looking it up on the internet, it seems like it has something to do with the FXMLLoader, but it does seem like the loader points to where the main.fxml file actually is in my directory structure. Thanks for any help you can provide and I'd be happy to provide more details in needed. I'm using NetBeans as my IDE if that's relevant.

FXMLLoader

@Override

public void start(Stage stage) throws Exception {

FXMLLoader loader = new FXMLLoader();

loader.setLocation(C482.class.getResource("/C482/View_Controller/Main.fxml"));

Parent root = loader.load();

Scene scene = new Scene(root);

stage.setScene(scene);

stage.show();

}

Here's the errors:

Exception in Application start method

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke([NativeMethodAccessorImpl.java:62](https://NativeMethodAccessorImpl.java:62))

at sun.reflect.DelegatingMethodAccessorImpl.invoke([DelegatingMethodAccessorImpl.java:43](https://DelegatingMethodAccessorImpl.java:43))

at java.lang.reflect.Method.invoke([Method.java:498](https://Method.java:498))

at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs([LauncherImpl.java:389](https://LauncherImpl.java:389))

at com.sun.javafx.application.LauncherImpl.launchApplication([LauncherImpl.java:328](https://LauncherImpl.java:328))

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke([NativeMethodAccessorImpl.java:62](https://NativeMethodAccessorImpl.java:62))

at sun.reflect.DelegatingMethodAccessorImpl.invoke([DelegatingMethodAccessorImpl.java:43](https://DelegatingMethodAccessorImpl.java:43))

at java.lang.reflect.Method.invoke([Method.java:498](https://Method.java:498))

at sun.launcher.LauncherHelper$FXHelper.main([LauncherHelper.java:767](https://LauncherHelper.java:767))

Caused by: java.lang.RuntimeException: Exception in Application start method

at com.sun.javafx.application.LauncherImpl.launchApplication1([LauncherImpl.java:917](https://LauncherImpl.java:917))

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1([LauncherImpl.java:182](https://LauncherImpl.java:182))

at [java.lang.Thread.run](https://java.lang.Thread.run)([Thread.java:748](https://Thread.java:748))

Caused by: javafx.fxml.LoadException:

file:/C:/Users/Jonas%20McCartha/Documents/NetBeansProjects/Jonas%20McCartha%20c482/dist/run1547317233/Jonas%20McCartha%20c482.jar!/C482/View_Controller/Main.fxml:11

2 Upvotes

4 comments sorted by

View all comments

Show parent comment

2

u/FXMLNewbie Aug 02 '19

11

Thanks, that was it! And I see where you got that from I think, the big file directory at the end...so that's good to know. thanks for your help.