title: Problem in adding Icon to a JFrame
body: <p>I have tried several methods to add an Icon to a JFrame. Every method work perfectly when I run it using the source code. </p>
  
  <p>for example:</p>
  
  <pre><code>jframe.setIconImage(Toolkit.getDefaultToolkit().getImage("iconimages/icon.png"));
  </code></pre>
  
  <p>But none of them work when I run it using the jar file. I know the problem is with the path of the image file. How can I solve this?</p>
  
  <p>Edit:</p>
  
  <pre><code>public Ui() { 
     initComponents(); 
     setLocationRelativeTo(null); 
     this.setIconImage(getImageIcon("icon.png").getImage());
  } 
  
  private ImageIcon getImageIcon(String fileName) {
     String imageDirectory = "iconimages/"; 
     imgURL = getClass().getResource(imageDirectory + fileName); 
     return new ImageIcon(imgURL); 
  }
  </code></pre>
  
  <p>I tried this but now I get a null pointer exception.</p>
  
  <p><code>--------------------------------------------------------------------------------</code></p>
  
  <p>Edit [Solution] : <strong>I found the solution.</strong></p>
  
  <p>I added <code>../</code> to the path additionally and it works perfectly!!! :D</p>
  
  <pre><code> ImageIcon imageIcon = new ImageIcon("../imageicons/icon.png");
   this.setIconImage(imageIcon.getImage());
  </code></pre>
  
  <p>Thanks all for try to help me. :)</p>