title: Java: setting an icon in a jar application
body: <p>I've developed an application that I export into a runnable jar (including the libraries it needs). Everything works fine.</p>
  
  <p>When running the app from Eclipse I'm able to change the icon that the application window shows:</p>
  
  <pre><code>BufferedImage image = null;
  try {
     image = ImageIO.read(this.getClass().getResource("AT42.png"));
  } catch (IOException e) {e.printStackTrace();}
  this.setIconImage(image);   
  </code></pre>
  
  <p>The picture is placed in my .class files directory.</p>
  
  <p>When I run it from Eclipse it shows the icon, but when I create a runnable jar and execute it I get the following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
  Caused by: java.lang.IllegalArgumentException: input == null!
          at javax.imageio.ImageIO.read(Unknown Source)
          at com.tools.at4.UserInterface.&lt;init&gt;(UserInterface.java:43)
          at com.tools.at4.GeneradorInformes.main(GeneradorInformes.java:8)
          ... 5 more
  </code></pre>
  
  <p>I guess the icon is not include in the jar file, my question is, is there any way of incluiding it, so that when I run the jar file the windows that are created show my icon instead of the Java cup?</p>
  
  <p>Thanks!!</p>