I have the following project setup (Maven Project):
And the absolute path: C:\Users\jenny\IdeaProjects\gameapp\client\src\main\resources\images\game\black_market.png
This code throws a Nullpointerexception:
private void setUpImage(ImageView image){
Platform.runLater(()->{
var url = getClass().getResourceAsStream("images/game/black_market.png");
System.out.println(url.toString());
Image img = new Image(url);
image.setImage(img);
});
}
It's probably because the filepath is incorrect but I don't really know how to fix it on my own. I've tried for the last 2-3 hours researching similar problems on Stackoverflow.
The ImageView that gets passed on this function is a reference to an ImageView. My function should load the image and put it into the passed ImageView. To be honest, I don't actually know if that will work since Java is pass by value.