title: Loading ImageIcon from JAR or file system
body: <p>I have a simple program that needs to display images.
  I know how to do this running the code from Eclipse and I know how to do it running from a JAR file, but I'd like a solution that works in both cases.</p>
  
  <p>Eclipse project is as such:</p>
  
  <pre><code>- Project (java)
    - src
      - controller
        - Main.java
      - ui
        - Display.java
    - images
      - image.jpg
  </code></pre>
  
  <p>The code snippet that works from within Eclipse:</p>
  
  <pre><code>ImageIcon image = new ImageIcon("images/image.jpg);
  </code></pre>
  
  <p>The one that works for a JAR (all in a single JAR file):</p>
  
  <pre><code>java.net.URL imgURL = getClass().getResource("/images/image.jpg");
  ImageIcon image = new ImageIcon(imgURL);
  </code></pre>
  
  <p>What would I need to change in order to get a single piece of code that works in both situations?</p>