0

I just converted a Java Web Start application to an applet. It is taking more time than before to load, so I enabled the highest level of logging in the console.

The program uses a lot of resources stored in .jar files. However, it tries to download some of them from the codebase on the web server! The response is obviously 404, but it still wastes a lot of time since there are so many files. And once everything finally loads, all of the resources work as they should! Why is it doing this, and how do I get it to stop?

Resource loading code:

public static BufferedImage loadImage(String name, String path) throws IOException
{
    URL url = AssetManager.class.getResource(path.replace("resource://", "resources/"));
    if(url == null)
        throw new IOException("Resource not found: "+path);

    BufferedImage image = ImageIO.read(url);
    images.put(name, image);
    return image;
}
5
  • post the code that is trying to load the resources Commented Apr 28, 2011 at 1:26
  • I edited the code into the original question. "resources" is a folder inside one of the .jars (but not the one that this code is in, could that be a problem?) Commented Apr 28, 2011 at 21:46
  • what happens if you do something like, BufferedImage image = ImageIO.read(url.openStream()); (but make sure to close the stream in a finally block) Commented Apr 29, 2011 at 4:15
  • I tried that, it didn't fix the problem. Commented May 1, 2011 at 14:03
  • What do you get when you do System.out.println(((URLClassLoader) AssetManager.class.getClassLoader()).getURLs()) Commented May 1, 2011 at 14:32

1 Answer 1

1

I observed this, too, and I'm not really sure how to avoid the plugin loading classes from HTTP instead of the jars. You could try to use jar indexes (so the VM would know which class/resource is in which jar). There might be some applet tag or JNLP file option to avoid this, too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.