I am trying to load a bmp image into my java program, Ive tried many different solutions, none of them are working. Every attempt leads to a NullPointerException. My NetBeans Project directory is set up as:
Project/src/main/java/com/username/programName/ - Where I have my code Project/src/main/resources/ - Where I have img.bmp
This is in java 1.8.
public static void main(String[] args) {
FileHandler handler = new FileHandler();
handler.test();
}
}
void test() {
File file = new File(getClass().getClassLoader().getResource("src/main/resources/img.bmp").getFile());
}
}
I would simply like to be able to load the image. Everything I've tried so far has resulted in NullPointer.