Java Plugin and GIFs from Jar file...

This used to work and I haven't looked at it for a while. First thing I did is run the old java applet web page with the old jar file, kinda just to lay eyes on the thing again.

It had to download a new plug-in from Sun, and upon doing so, reports a new error indicating that the value for the cache_version attribute in the HTML is incorrect. It was 1.0 (always has been) and the plugin says it needs to be in X.X.X.X format instead.

So, that isn't a nice change to make in the plugin at this time.However, if I just click okay and close the error dialog, at least it works fine after that.

In my attempt to get rid of the dialog I change the cache version to 1.0.0.0, upon doing this

the toolbar images no longer load, it says there is a java.io.FilePermission error.

We'll it doesn't make any sense that a mere change to cache version caused that so I changed the version back to the apparently erroneous value of 1.0, and then the toolbar images work again ! But I get the permission error.

Any ideas how I can fix these pesky images loading from a jar ?

Do you have any code that loads images out of a jar in an applet succesfully ?

Or have any suggestions on what I could try ?

Below is the code I'm using to load the images, where icoXXXX is a ImageIcon object, and fileameXXXX is a string containing a relative file path such as "images/highcolor/toc_color.gif" (this code executes in the applet's init() method (called by the plugin):

java.net.URL urlToc = getClass().getResource(filenameToc);

java.net.URL urlTocBW= getClass().getResource(filenameTocBW);

[1663 byte] By [jwilleke] at [2007-9-26 4:11:26]
# 1

dunno why but

getClass().$blah... wouldn't work for getting images in an applet from a jar for me.

But this does:

Class c = Class.forName("java.lang.Object");

InputStream in = c.getResourceAsStream("/images/myImage.gif");

byte[] buffer = new byte[in.available()];

in.read(buffer);

icon = new ImageIcon(buffer);

when included with the usual default exception handling.

Lemme know if that doesn't work for you.

cheers

-Ragu

Overweight is when you step on your dog's tail and it dies.

ragude at 2007-6-29 13:16:20 > top of Java-index,Desktop,Deploying...