Skip to content
Advertisement

Exception in Application start method java.lang.reflect.InvocationTargetException

I am just starting out with JavaFX, and I am trying to build a simple application with a label, text field and button which, when clicked, sets the label’s value to that of the text field’s. Everything was going well until I connected the controller to the Main file. Here’s my code:

Main.java

JavaScript

MainWindowView.fxml

JavaScript

MainWindowController.java

JavaScript

I have tried multiple answers found on StackOverflow, but all that I have found were from 2 years ago and did not make any positive effect on my code.

EDIT: Stack trace here:

JavaScript

Advertisement

Answer

For anyone who has this exact same problem in the future, as James_D and the other answer contributors mentioned, removing the “/” at the beginning of the path fixes the problem so use

JavaScript

instead of

JavaScript
Advertisement