[quote]if your image is in the jar, you should use
myImage = javax.imageio.ImageIO.read( ClassLoader.getSystemResource( “myImage.xxx”));
It will look in classpath, thus in jar.
[/quote]
This will only work in jars. If you’d like to load resources whether they are inside your jar or just in the same dir as your jar you could get the URL like this:
// Try to get URL
URL url = this.getClass().getClassLoader().getResource(FilePath);
// Not in JAR? (Note : If run as class file this will find your files in the same dir as the class file)
if (url == null)
{
// Try to get file
File f = new File(System.getProperty(“user.dir”) + File.separator + FilePath);
// Check if it exists
if (f.exists())
{
url = f.toURL();
}
}
// Still not found? Bail
if (url == null)
{
return null;
}