JAR not showing images?
Ok, here's my problem:
I created a jar (something I've done many times before), but it's not working correctly. I have 3 java files in yet; usually I have one. I create objects of two of the classes in the main class; is there anything special I have to do when开发者_StackOverflow中文版 creating the objects? The images that I use are in a folder that is in the same folder as the JAR, so that's not a problem.
I can post code if you want/need, though I don't see how it'll do any help.
I have 3 java files in yet; ..
Put classes in Jar files, not .java source files.
( It surprises me that was the answer! ;)
The images that I use are in a folder that is in the same folder as the JAR, so that's not a problem.
Maybe it is a problem.
I presume that you are trying to access the images via the Class.getResourceAsStream(...)
or something like that. If so, the classloader will only see the image files if they are in a directory tree that is on the classpath. The way that you described it, the image files are NOT in the JAR file, and therefore you need a separate classpath entry for the directory.
(What would really help would be if you rewrote your question in clearer English ... and using the correct terminology. For instance: "I create objects of two of the classes in the main class" is nonsensical. )
精彩评论