My JavaFX project can load image in one machine, but same code cannot load the image in another machine.
I have the package structure (in src) - /com/mypackagestructure/view/images/ and this holds the image file.
I have the CSS file at - /com/mypackagestructure/view/Login.css
Login.css
.root {
-fx-background-image: url("/com/mypackagestructure/view/images/background.jpg");
-fx-background-repeat: stretch;
-fx-background-size: 100%;
-fx-background-color: transparent;
}
I have this exact same code in another machine (same OS, same Eclipse IDE and JDK/JRE (1.8) installed) and it works over there. But in this machine I get the following message-
Aug 08, 2016 3:36:39 PM com.sun.javafx.css.StyleManager getCachedImage
WARNING: Error loading image: file:/com/mypackagestructure/view/images/background.jpg
In the css if I make the following change, then it works.
-fx-background-image: url("images/background.jpg");
What is wrong with my way of referencing the image file? And why does it work on one machine and not in the other?