I just learned how to create Executable jar Files and package Folders into Jar files. The problem I have is that my Executable jar file loads the Image in the directory in which it was created, but once I move it somewhere else It doesn’t load the Image.
This will load an image from within a jar file.
String fileName = ...;
BufferedImage img = ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream( fileName ));
This piece of code did it for me…
URL imageURL = getClass().getResource(“ImageDirectory/ImageFile.jpg”);
Image Picture = new ImageIcon(imageURL).getImage();
Thanks Zoto.