Strange error with an applet

I’ve created an applet for a school project, and unfortunately it seems like no one but me can play it. When I run it from my computer, (which is Java 1.5), it loads and plays flawlessly. However, whenever I ask friends to test it for me, (and they have 1.4.x), it crashes on loading. At first I assumed it was an issue with which version I compiled it in, but after compiling it with 1.4.1 and asking them to test it again, it still crashes. The game is located at http://www.epikgames.com/test.html if you would like to try it yourself and see if you can run it. If you do get an error and can explain why it doesn’t load, I would much appreciate it. The reason i’m posting in this forum is that it seems that the error is ImageIO related. Thanks in advance!

yeah, there are several issues with ImageIO in 1.4.1.

Advise your friend to upgrade his JVM to 1.4.2 or 1.5.

Unfortunately I don’t think its as simple as upgrading from 1.4.1 to 1.4.2. Again if you could take a minute to try the page yourself, I’d appreciate it.

Works with 1.5 (though whatever method you are using for Threading/repainting sux - its horribly stuttery)

Can’t test it with 1.4.x, I don’t have them installed.

Here’s your problem:


java.util.zip.ZipException: invalid stored block lengths
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:140)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at com.sun.imageio.plugins.png.PNGImageReader.decodePass(PNGImageReader.
java:1165)
        at com.sun.imageio.plugins.png.PNGImageReader.decodeImage(PNGImageReader
.java:1276)
        at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.j
ava:1362)
        at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1
530)
        at javax.imageio.ImageIO.read(ImageIO.java:1384)
        at javax.imageio.ImageIO.read(ImageIO.java:1348)
        at com.epikgames.Lander.LanderApplet.loadImage(LanderApplet.java:119)
        at com.epikgames.Lander.LanderApplet.init(LanderApplet.java:104)
        at sun.applet.AppletPanel.run(AppletPanel.java:353)

We need to see your “loadImage” code. I have a sneaky suspicion that you’re doing something kind of wierd.

Also, the tag:

code="com.epikgames.Lander.LanderApplet.class"

shouldn’t have the “.class” on it. That should read:

code="com.epikgames.Lander.LanderApplet"

Probably the standard ImageIO bug, wich was fixed in 1.5. You need to give ImageIO a input stream wrapped in a BufferedInputStream, like this:

sourceImage = ImageIO.read(new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream("pathToFile")));

Here’s my loadImage() code:


public BufferedImage loadImage(String file) {
            BufferedImage image;
            
            try {
                  image = ImageIO.read(LanderApplet.class.getClassLoader().getResource(file));
            } catch(IOException e) {
                  e.printStackTrace();
                  return null;
            }
            
            return image;
      }

I’ll give tom’s suggestion a try, that’s probably what the problem is, right now. If you get another chance, see if you can run it after I make the changes.

I appreciate the feedback, but I’d have to see what you’re experiencing, as the applet runs relatively smoothly on my laptop, (2.6 ghz 512 ram, 64mb Radeon 7500). I am manually double buffering which means that the applet currently is not making use of Vram, which may be the reason you’re experiencing inadequate performance. I tried to implement the standard double buffering system but for one reason or another I couldn’t get it to work and I was crunched for time so I had to drop it. I’m really not concerned with its visual performance right now as much as the accuracy of the physics, most of which still has to be implemented. Anyways, thanks very much for everyone’s help, it is much appreciated!

It worked now with Java 1.4.? in IE.

Very cool - thank you for your help!