views:

319

answers:

3

We have a large Java application that run as applet or Java Web Start. And it grow more and more. Typical a user need only a small part of the classes. Because Java does not know which class can it found in which jar file that it load all jar files until it find the class. If it will load a class that not exist (for example a resource bundle) then it load all jar files. This reduce the start time on a small bandwidth very large.

Is there a small framework with which we can load the plugins only if needed? Or better if needed and on background?

Of course the framework should not delay the start time self with it large size.

I think it should use a URLClassLoader for downloading.

A: 

I think (without jnlp I'm not sure) you already use the download property:

<jar href="sound.jar" download="lazy"/>

Since webstart has no information about the jar contents I assume it loads all of them if the class is missing.

Although I've never tried, but there is a <package> tag where you can give some hints to the webstart where to search for classes. Checks this (very short) documentation.

asalamon74
+1  A: 

This is not a direct answer to your question, but you might be able to mitigate the slow downloads by using Pack200 to significantly reduce the size of your JAR files. I've previously written about how effective this can be.

Other than that, I'd agree asalamon74's suggestion to use lazy downloading of JAR files.

Perhaps you can optimise the order of the JARs so that those that contain classes that will be loaded first appear earlier?

Dan Dyer
+1  A: 

I've heard that you can implement custom class loaders and I've seen tutorials on this subject. With this you should be able to control what gets downloaded more precisely. Sorry, I haven't tried this myself.

sjbotha