Loading images from Jar Files

Created 12 September 2002 00:00
  try {
    URL url = FreeArchiver.class.getResource("/images/yourimg.gif"); 
    // the following line is necessary to be able to catch the exception if
    // the image does not exist in the resource
    url.getFile();
    Image img = Toolkit.getDefaultToolkit().getImage(url); 
    setIconImage(img);
  }
  catch (Exception e) {
    System.err.println("Unable to load image from archive.");
  }