If your app. is in Jar files and the image is an application resource, it will also be in a Jar file.
The ImageIcon
constructor that accepts a String
presumes the String
represents a file path/name. A File
object cannot be established to a resource in a Jar. For resources in a Jar, it is necessary to access them by URL
.
To get an URL
to something in a Jar, use something like..
URL urlToImage = this.getClass().getResource("/media/link_walk.png");
// Check the URL!
System.out.println("urlToImage is " + urlToImage);
Then use the ImageIcon
constructor that accepts an URL
.