I've spent almost 2 days in trying to load files from inside of my netbeans project, but it always gives NullPointException.
currently my directory looks like:
JavaFXApplication:
- src
--Manifest (contains Manifest.java)
--images (inside Manifest package aka Manifest.images)
--server.jpg (inside images package)
I'm trying to load the server.jpg from images package, but it always return NULL.
Here is the snippet of my code:
try {
rect.setFill(new ImagePattern(new Image(Manifest.class.getResourceAsStream("images\\server.jpg"))));
} catch (NullPointerException e) {
System.out.println(Manifest.class.getResourceAsStream("server.jpg"));
}
Exactly 2 days before, I saw this code from a YouTube Tutorial, and it doesn't worked. Try many of those solutions from here, but nothing yield for me.And suddenly it worked. Next day, tried to run the same code, and again same NULL error.
Can you guys please help me. I'm totally new to JavaFX. Don't have much experience with it.