0

I am using netbeans to create a JavaFX application, using scenebuilder.

My program is able to compile, but when I run I get null pointer exception error.

I've narrowed the problem down to the getResource() function returning null, and I have looked at other solutions, but they do not fix my problem.

Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

I have tried giving the absolute file path, as well at the local path, and as you can see the relative path. I have also checked other files as a test, but whatever I pass returns null.

This is my src folder: src image

Luca
  • 31
  • 4
  • If you are using the forward slash, you are telling the lookup to start at the root of the class path (the beginning of the sources folder. If you take out the slash, the lookup will start from where the class is located. That is what you want with your current setup – Paul Samsotha Feb 20 '21 at 08:29
  • Regardless, it doesn't work without the slash – Luca Feb 20 '21 at 08:30

0 Answers0