Downloading an image from a Jar file at runtime is the same as loading an image when executing from an IDE, such as netbeans, the difference is that when loading an image from a JAR file, the path must be correct and case sensitive (very important). It works for me
image1 = new javax.swing.ImageIcon (getClass (). getResource ("/ Pictures / firstgame / habitat1.jpg"));
img = image1.getImage (). getScaledInstance (lblhabitat1.getWidth (), lblhabitat1.getHeight (), Image.SCALE_SMOOTH);
lblhabitat1.setIcon (new ImageIcon (img));
if p in "/Pictures/firstgame/habitat1.jpg" is lowercase, it will not work. checking spaces, cases and spelling
Tobore Igbe Dec 07 '15 at 16:10 2015-12-07 16:10
source share