lundi 9 mars 2015

JavaFX getResource return null when running in browser


Vote count:

0




I have a javafx application and I store all fxml files in src/foo/bar/fxui folder. I use the code below to refer to fxml file:



FXMLLoader loader = new FXMLLoader(getClass().getResource("/foo/bar/fxui/file.fxml"));
Parent root = (Parent) loader.load();


The calling class is in src/foo/bar.


This code works well when I run it in Eclipse. To deploy it I export it as JAR using efxclipse. It also works well when I directly run the JAR file. However, the code breaks when I try to launch this application inside a browser (Chrome/IE). It tells me "Location is not set". I have troubleshooted that the following line returns null:



getClass().getResource("/foo/bar/fxui/file.fxml")


Therefore, it seems to me that it is a problem of not able to get the file by the path specified. I have tried putting fxml files into main/resources/foo/bar/fxui folder. It does not work either.


I have spent one whole day on this problem. Any help is much appreciated!



asked 1 min ago







JavaFX getResource return null when running in browser

Aucun commentaire:

Enregistrer un commentaire