hello,
i used to do this when i want to load an image into the game
String path = "D:/My Graphics/hero.png";
ImageIcon ii = new ImageIcon(path);
Image image = ii.getImage();
but when i tried to export the project into a Runnable Jar and test it in another pc, everything disappeared, and it make sense cause the other computers doesn’t have that path
so i did some research and tried this :
String img = "graphics/hero.png";
Image image;
URL path = this.getClass().getResource(img);
if (path != null) {
ImageIcon ii = new ImageIcon(path, "hero");
image = ii.getImage();
} else {
System.err.println("Couldn't find file: " + path);
}
it always print the error and i don’t get my image
this is a screen of my work space
http://s22.postimg.org/ieyqokbe9/Capture.png
thank you