title: How to put images in .jar file?
body: <p>first i'd like to say that yes, i searched, i searched real hard and unfortunatelly, i did not find any answer good enough for me, i think i know what to do, but i don't know how to do it ! Well, i put a lot of images in my program, and it worked out great, when i run on my computer the images appear and there's no problem, but i can't make the images to appear in other pc's ! Everytime i put the .jar in another machine, the images disappear... Well, i think i have to create a package with the images folder right ? But i don't know how to do it, or what to do after that ! If someone could give me a fully example, that would be awesome... Here's my code, please let me know if can improve the question, i'm just new here ! </p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  public class IMC extends JFrame {
      private static final long serialVersionUID = 1L;
  
      private JButton ok;
      private JButton sair;
      private JTextField txt1;
      private JTextField txt2;
      private Dimension dim,dim2,dim3;
      private JLabel l1,l2,l3,l4;
      private Font letra;
      private float tamanho;
      private float peso;
      private float imc;
  
          public IMC (){
              dim = new Dimension(650,500);
              dim2 = new Dimension (340,25);
              dim3 = new Dimension (75,35);
              setTitle("Calcule seu IMC!");
              setSize(dim);
              setLocation(190,100);
              setResizable(false);
              setBackground(new Color(250,250,200));
              Color lightGray = Color.gray.brighter();
              getContentPane().setBackground(lightGray);
              setLayout(null);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
  
              JMenuBar mBar = new JMenuBar();
  
              JMenu opcoes = new JMenu("Opções");
              JMenuItem sobreIMC = new JMenuItem("Sobre");
              JMenuItem sobreMim = new JMenuItem("Sobre mim");
  
              opcoes.add(sobreIMC);
              opcoes.add(sobreMim);
  
              JMenu fechar = new JMenu("Fechar");
              JMenuItem fecharIMC = new JMenuItem("Fechar");
  
              fechar.add(fecharIMC);
  
              mBar.add(opcoes);
              mBar.add(fechar);
              setJMenuBar(mBar);
  
              tamanho = 0;
              peso = 0;
  
              letra = new Font("Arial",Font.PLAIN,14);
              setFont(letra);
  
              l1 = new JLabel();
              l1.setText("Complete os campos abaixo:");
              l1.setSize(250,70);
              l1.setLocation(100,0);
              l1.setFont(new Font("Arial", Font.BOLD,15));
              this.add(l1);
  
              l2 = new JLabel();
              l2.setText("Insira sua altura:");
              l2.setBounds(47,85,150,150);
              l2.setFont(new Font("Arial", Font.BOLD,13));
              this.add(l2);
  
              l3 = new JLabel();
              l3.setText("Insira seu peso:");
              l3.setBounds(47,165,150,150);
              l3.setFont(new Font("Arial", Font.BOLD,13));
              this.add(l3);
  
              l4 = new JLabel();
              l4.setText("Gabriel Ozzy Santos");
              l4.setBounds(230,270,150,100);
              l4.setFont(new Font ("Verdana", Font.ITALIC,15));
              this.add(l4);
  
              ImageIcon im = new ImageIcon("C:/Users/Gabriel Ozzy/Downloads/Java3.1.jpg");
              JLabel l5 = new JLabel(im);
              l5.setBounds(255,350,120,120);
              this.add(l5);
  
              ok = new JButton();
              ok.setText("OK");
              ok.setLocation(180,390);
              ok.setSize(dim3);
              ok.setBackground(new Color(157,182,210));
              ok.setForeground(Color.white);
              this.add(ok);
  
              sair = new JButton();
              sair.setText("Sair");
              sair.setLocation(370,390);
              sair.setSize(dim3);
              sair.setBackground(new Color (157,180,210));
              sair.setForeground(Color.white);
              this.add(sair);
  
              txt1 = new JTextField();
              txt1.setSize(dim2);
              txt1.setLocation(160,150);
              this.add(txt1);
  
              txt2 = new JTextField();
              txt2.setSize(dim2);
              txt2.setLocation(160,230);
              this.add(txt2);
  
  
          ok.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent evt){
                  String t1 = txt1.getText();
                  if(!"".equals(t1))
                  tamanho = Float.parseFloat(t1);
  
                  String t2 = txt2.getText();
                  if(!"".equals(t2))
                  peso = Float.parseFloat(t2);
                  imc = (peso/(tamanho*tamanho));
  
                  if (ok != null){
                      ImageIcon info = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg"));
                      JOptionPane.showMessageDialog(null,"Seu IMC é:"+imc,"Resultado do IMC",0,info);
                  }
                  if (imc &lt;18.5){
                      ImageIcon info2 = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg"));
                      JOptionPane.showMessageDialog(null,"Você parece o esqueleto do HE-MAN!","Seu magrelo !",0, info2);
                  }
                  if (imc &gt; 18.5 &amp;&amp; imc &lt; 24.9){
                      ImageIcon info3 = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg"));
                      JOptionPane.showMessageDialog(null, "Ta no peso certinho :)", "Continue assim!",0,info3);
                  }
                  if (imc &gt; 24.9 &amp;&amp; imc &lt; 29.9){
                      ImageIcon info4 = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg"));
                      JOptionPane.showMessageDialog(null,"Você está ficando gordinho! :(", "Emagrece!",0,info4);
                  }
                  if (imc &gt; 29.9 &amp;&amp; imc &lt; 34.9){
                      ImageIcon info5 = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg"));
                      JOptionPane.showMessageDialog(null,"Gordo!","Baleia!",0,info5);
                  }
                  if (imc &gt; 34.9){
                      ImageIcon info6 = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg"));
                      JOptionPane.showMessageDialog(null,"Obeso mórbido!", "Orca Assassina!",0,info6);
                  }
                  tamanho = 0;
                  peso = 0;
                  txt1.setText("");
                  txt2.setText("");
              }
          });
          sair.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent evt){
                  System.exit(0);
              }
          });
          sobreIMC.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent evt){
                  Icon about = new ImageIcon ("C:/Users/Gabriel Ozzy/Downloads/Java2.jpg");
                  JOptionPane.showMessageDialog(null,"Programado em Java 7 - Plataforma Eclipse","Sobre o software",0,about);
              }
          });
          sobreMim.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent evt){
                  Icon about2 = new ImageIcon ("C:/Users/Gabriel Ozzy/Downloads/Java2.jpg");
                  JOptionPane.showMessageDialog(null,"Programador: Gabriel Ozzy Santos","Sobre o desenvolvedor",0,about2);
              }
          });
          fecharIMC.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent evt){
                  System.exit(0);
              }
          });
          }
          public static void main (String [] args){
              new IMC().setVisible(true);
          }
  }
  </code></pre>