I'm been stuck for a while trying to load images. I've been looking everywhere, but most "solutions" such as .getResource, .getResourceAsStream have not been working for me.
Recently I tried looking at the path that the .jar is pulling the file from, and it seems to be working properly
I got the .jar to print to console the path that it was following using the code
// (path is \Resources\(image).png)
System.out.println(new File (ImageLoader.class.getProtectionDomain().getCodeSource()
.getLocation().toURI().getPath() + path));
giving me something like C:\path\Desktop\game.jar\Resources\background.png
I opened my .jar file using an archiver and it gave me the same path. C:\path\Desktop\game.jar\Resources\ and all my images are there.
Loading from my IDE works properly, but not from the .jar. (the issue shouldn't have to do with case sensitivity). when I actually try to load it using
ImageIO.read(new File(ImageLoader.class...), it doesn't work (returns null);
Does this problem have to do with the .jar not being to access the files inside itself because of permission issues or something else? Thanks!