I'm trying to load two images from a .jar file that contains two folders (and the META-INF, but that doesn't matter in this situation), volatileimagetest (where the code is) and images (where the two images are).When I run the code (below) before it's packaged into a .jar, it runs just fine. I have two directories, volatileimagetest (where the code is) and images (where the two images are). The directories are exactly the same as in the .jar, but not in a jar file.

This loads the images when running outside the .jar file. I printed url to System.out, and got this: "file:/C:/Documents%20and%20Settings/Owner/My%20Documents/Java/VolatileImage/build/classes/images/img1.png". I feel I should just say the directory volatileimagetest is located in the same directory as images, and contains all class files.

When I run this as a .jar, I get a NullPointException, and I narrowed it down to the line "URL url = getClass().getResource("/images/img1.png");", with getResource() returning null.

I usually do. Must have been a fluke with the image editing/creation program I was using (it defaults to upper. I usually remember to change it to lower). Thanks for pointing that out. I am running Windows, so I'm used to case-insensitivity. I'll try changing that when I get to my compiler (at school right now...).

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org