title: Setting JLabel icon through code
body: <p>The following code will only work on my computer but not on others:</p>
  
  <pre><code>doll.setIcon(new ImageIcon("C:/Users/akashsharma/Documents/NetBeansProjects/Hangman/src/win/images/G.jpg"));
  </code></pre>
  
  <p>I have tried using the following but it results in a <code>NullPointerException</code>.</p>
  
  <pre><code>getClass().getResource("/images/G.jpg")
  </code></pre>
  
  <p>What should I do to solve this problem?</p>
  
  <p><a href="https://i.stack.imgur.com/4oPQL.jpg" rel="nofollow noreferrer">The arrangement of files in the IDE</a></p>
  
  <p><img src="https://i.stack.imgur.com/4oPQL.jpg"></p>