title: Maven packaging images in the root of the jar file
body: <p>Folks,</p>
  
  <p>I am developing a Java application using Eclipse. Maven is used to create the final jar file.</p>
  
  <p>In the application, I use some image icons for the buttons. Following some instructions on the Internet, I created a "source" directory by clicking on the project. I named the source directory as "res" and moved my images to this directory.</p>
  
  <pre><code>
  public static ImageIcon getIcon() {
    if (isThisJarfile()) {
       URL url = this.class.getResources("/res/myicon.png");
       return new ImageIcon(url);
    }else {
       return new ImageIcon("/res/myicon.png");
    }
  }
  </code></pre>
  
  <p>This works fine when the app is not packaged as a jar file (great for debugging). However, when maven packages it, I see that the images are put in the root directory of the jar file. The following call works:</p>
  
  <pre>
      URL url = this.class.getResource("/myicon.png");
  </pre>
  
  <p>I am wondering if there is some step that I overlooked.</p>
  
  <p>Note that I didn't have to do anything special to pom.xml for the images. Maven automatically picked them up (except that it is putting them in the wrong location).</p>
  
  <p>Thank you in advance for your help.</p>
  
  <p>Regards,
  Peter</p>