• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes

Problem :

I am always getting below error while working with JavaFX,

exception in application start method java.lang.reflect.invocationtargetexception

I am getting the error while trying below code

// main window
    public void mainWindow() {
        try {
            // view
            FXMLLoader loader = new FXMLLoader(Main.class.getResource("/MainWindowView.fxml"));
            AnchorPane pane = loader.load();
by (300 points)  
edited by

1 Answer

0 votes

Possible Cause:

It seems "/" is given at the beginning of the path for "FXMLLoader".

Solution :

If you are using code as below:

FXMLLoader fxmloader = new FXMLLoader(Main.class.getResource("/MainWindowView.fxml")); 

Then please remove the "/" given at the beginning of the path for "FXMLLoader" as below

FXMLLoader fxmloader = new FXMLLoader(Main.class.getResource("MainWindowView.fxml"));

And your issue will be resolved.


Please dont give the "/" at the beginning of the path for "FXMLLoader".

Further Readings:


by (33.3k points)  
edited by