I tried almost everything, but still have this problem. I have the following setup: I have an images.jar file containing a folder called "images" in which there are several image files. I add images.jar to the java build path of the project in eclipse, and I tried to use the following code to access individual images in the bank:
URL url = this.getClass().getResource("images/a.png");
ImageIcon icon = new ImageIcon (url);
Unfortunately, the URL object is always NULL. I don't think this has anything to do with where I put the image.jar file, as it is added to the classpath in eclipse. I also tried using the path "/images/a.png", but still the same question. Any suggestion would be very welcome! Thank.
source
share