How do I read an Image from a JAR file with Netscape browsers?

John Zukowski

The Communicator 4.x browsers do not implement the Class.getResource(), ClassLoader.getResource(), and ClassLoader.getSystemResource() methods. You need to use the Class.getResourceAsStream(), ClassLoader.getResourceAsStream(), or ClassLoader.getSystemResourceAsStream() methods instead, respectively. See http://developer.netscape.com/docs/technote/java/getresource/getresource.html for more information.

With that said, the following will load an Image:

InputStream in = getClass().getResourceAsStream("image.gif"); 
byte buffer[] = new byte[in.available()]; 
Image image = Toolkit.getDefaultToolkit().createImage(buffer);