开发者

Java applet resource loading problem

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 t开发者_Go百科o 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;
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜