Loading ImageIcon from JAR or file system

Put the images folder inside the src folder, and Eclipse will copy the images into the target folder (bin or classes, generally), which will make them available from the classpath, just as if they were in your jar in the released version of your app.

getResource() doesn’t look in a jar. It looks in the classpath of the classloader. Whether the image is in a jar or not is thus not important. It must be in the classpath. And obviously the target folder of eclipse (bin or classes, generally) is in the runtime classpath of the app when you launch it from Eclipse.

Leave a Comment