Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading slash in getResource() #89

Open
aliaksei135 opened this issue Jun 7, 2021 · 1 comment
Open

Leading slash in getResource() #89

aliaksei135 opened this issue Jun 7, 2021 · 1 comment

Comments

@aliaksei135
Copy link

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 ?

@koppor
Copy link

koppor commented May 27, 2024

I think, it is even more todo here. One should use Streams instead of Paths. See JabRef#16 for details.

In your concrete case, it seems there is a mis-placement of your resources. Normally, the directory structure of resources should match the directory structure of the classes. See https://stackoverflow.com/a/41781868/873282 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants