Antonio Antonio - 8 months ago 26
Java Question

Images are loading in eclipse, but are not working in exported Jar

Title says it all, when I compile in eclipse it works fine, when I Export to a Jar file, they don't show up.

If you need anymore of the code, I will provide.

Image sprite = new ImageIcon("Sprites/Characters/spikeEnemy.png").getImage();

sprite = (e) ? new ImageIcon("Sprites/enemyProjectile.png").getImage() : new ImageIcon("Sprites/projectile.png").getImage();

(e: true for enemy, false for ally) sprite is declared earlier as (private Image sprite)


enter image description hereyou need to use getClassLoader: put the picture inside the src forlder

Image sprite =;

-> src /icons/icon.png"icons/icon.png"));

this whay the image will be inside the executable jar