afterburner.fx icon indicating copy to clipboard operation
afterburner.fx copied to clipboard

Leading slash in getResource()

Open aliaksei135 opened this issue 3 years ago • 1 comments

I have migrated an app from Java 8 to 11 where afterburner.fx was working fine on 8. I have also used maven for all the deps. Now I cannot find the correct .fxml resources, which are still in the same place as before.

Caused by: java.lang.IllegalStateException: Cannot load file Main.fxml

My project structure:

|_ src
  |_ java
     |_ <package>
        |_ ui
           |_ main
              |_ main.fxml
              |_ MainView.java
              |_ MainPresenter.java
              |_ main.css
pom.xml

After breaking into the debugger and snooping around a bit:

getClass().getResource("main.fxml");  // -> null, file not found

getClass().getResource("/main.fxml");  // -> this works,  file found

It seems that the leading slash fixes the issues, is this some kind of change between java versions that I didn't spot?

Is this related to #75 ?

aliaksei135 avatar Jun 07 '21 08:06 aliaksei135