JavaFX: Location is not set error even though it compiles and runs fine in IDE

When running my code in eclipse, it works flawlessly; however, when I export it, I get the "location is not set error" and don’t understand why. This specific part of the code work every time in exports prio to me converting the project to a maven project.

Here is the code snippet that causes the error:

private static void showMainView() throws IOException {     FXMLLoader loader = new FXMLLoader();     loader.setLocation(Main.class.getResource("MainGUI.fxml"));     System.out.println(loader.getLocation());     Main.mainLayout = loader.load();     Scene scene = new Scene(mainLayout);     Main.primaryStage.setScene(scene);     Main.primaryStage.show(); } 

Here is my file structure:

enter image description here

Here is the program working in the eclipse IDE with a print out of the file location

enter image description here

Here is the program error when troubleshooting in a powershell window with a print out of the file location being "null"

enter image description here

Could converting the project to a maven project have caused this? The reason I had to do this was the reflections library I’m using I could only find via a Maven dependency here https://github.com/ronmamo/reflections/tree/master

If more is needed to help troubleshoot, I’ll provide it to the best of my ability, because this one has me stumped

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.