I've made a game that uses images from another file. I asked this question: How can I get a program that uses external files into a JAR? which was marked as duplicate. The other question seemed to only deal with text files, and didn't help at all. I did a bit more research, and I think I need to put the project and the image files into one jar. I looked at this question: How can I include my icon when I export my project to a jar file, but I couldn't understand how to do it by reading the answer. I would have commented to ask for more clarity, but I need 50 reputation, which I don't have yet. I just need my program to be able to use image files when it is in jar form. It seems strange that things that work in an IDE don't always work in a jar. :P
This is the method I'm using to get the image files:
private Image retrieveImage(String filePath)
{
try{
Image image = (Image)ImageIO.read(new File(filePath));
return image;
} catch(Exception exc)
{
System.out.println(exc.toString());
return null;
}
}
The exception I get is: javax.imageio.IIOException: Can't read input file!
Thanks for all your help :)