Picture inside .jar file wont work when I export it.
I made a Java program that displays a picture, and it works perfectly in Eclipse, but when I export it to a .jar file, it wont display the picture. I just started learning Java, and I have no experience with creating Jar files and using files from inside the jar file.
Heres my code:
import javax.swing.*;
class displayPicture{
public static void main(String args[]){
JFrame frame = new JFrame();
ImageIcon icon = new ImageIcon("src/img.gif");
JLabel label = new JLabel(icon);
//Create the frame
frame.add(label);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
It shows the picture when I run it in Eclipse, but when I export it to a .jar file, it just shows a blank window.