title: Jframe.setContentPane(new JLabel([image])); background image not loading after built .jar
body: <p>I am having a problem with loading images, as I am trying to load a background for my launcher. It works when I run it in Eclipse, but when I export it to a jar file, it doesn't. I have paged through the already asked questions, No luck.</p>
  <p>Here is my code:</p>
  <pre><code>public void initializeJFrame(){
      
      ImageIcon bg = new ImageIcon(&quot;src/background.png&quot;);
      
      jb.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
              if (jta.getText().length() &lt; 3 || jta.getText().length() &gt; 16) {
                  System.exit(-1);
              } else {
                  try {
                      Runtime.getRuntime().exec(cmd, null, dir);
                  } catch (IOException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                  }
                  try {
                      Thread.sleep(500);
                  } catch (InterruptedException e1) {
                      // TODO Auto-generated catch block
                      e1.printStackTrace();
                  }
                  System.exit(0);
              }
          }
  
      });
      jf.setSize(WIDTH,HEIGHT);
      jf.setTitle(&quot;Cracked Launcher&quot;);
      jf.setLayout(null);
      jf.setContentPane(new JLabel(bg));
      jf.setResizable(false);
      jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);      
      t.start();
  </code></pre>
  <p>My image is in the <code>src</code> folder, nothing else. I cannot find what the problem is.</p>
  <p>Thanks for your support.</p>
  <p><a href="https://i.stack.imgur.com/TA21y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TA21y.png" alt="image" /></a> <a href="https://i.stack.imgur.com/jduQu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jduQu.png" alt="image2" /></a></p>