Packages and lazy download
I tried to use thelazy download feature for our application, but I had no success. The JAR files marked for lazy download are not loaded before application start, but shortly after start, although no class contained is referenced.
It seems Java Web Start is loading all jars if there is a request for a resource (class or other file) and this resource could not be found in downloaded jars.
Example: Many libraries try to load property files from classpath, although they do not exist in the classpath, so the developer can supply an own property file. Or the JRE tries to load property files for a given language and must fallback to a generic file. It that case the Java Web Start seems to search all JAR resource files, if the are marked as "lazy" or not. In my opinion, if I mark a JAR as "lazy" and use a package statement this JAR should be loaded only if a class of that package is referenced. Otherwise the "lazy download" feature seems to be useless.
Background: We try to deploy a application with Java Web Start. Only some users (less than 5%) call classes referencing to bigger libraries. Therefore we marked these libraries as "lazy", but it doesn't work. In that case nearly every user needs to load additional 2 MB of uselesse code.
Am I right or is there another solution for my problem?
Regards,
Frank
[1385 byte] By [
fbehrens] at [2007-9-26 4:08:57]

According to the JNLP specs, "Lazy" means - the resource does not necessarily have to be downloaded on to the client system BEFORE the application is launched. However, a JNLP client is always free to eagerly download all its resources, if it chooses to.
Does the application show lazy loading behaviour when
it is started from the command line?
(Just to insure that there really is no dependency that needs to be resolved by the loader)
If it is really a decision made by Web Start, you might think about using an alternative jnlp client (like open jnlp).
Regards,
Marc
> Does the application show lazy loading behaviour
> when it is started from the command line?
Yes.
Meanwhile a created for test purposes an extra test application with a few classes only. At first the program behaves as expected. The jar marked as "lazy" is not loaded and does not appear in the client cache directory. But when I try to load a non existing class with a package not associated to my "lazy" jar file, this jar is loaded by Java Web Start. Of course, I got an exception, but the "lazy" jar was loaded!
The result of this test is: I can not use the "lazy download" feature.
But what is this feature for? In (nearly) every application is a point, where some library or application code tries to load a resource/class which does not exist. This triggers the download of all jars marked for lazy download, although through the "package" statement the containing packages are determined. It makes for me nearly no difference if a jar is downloaded before application start or shortly after. I expect a lazy jar is downloaded if a class contained is needed.
> But when I try to load a non existing class
> with a package not associated to my "lazy" jar file,
> this jar is loaded by Java Web Start. Of course, I got
> an exception, but the "lazy" jar was loaded!
Hard to tell, if this is a bug or feature. Like someone wrote above, the jnlp client is allowed to decide to pull everything in.
Last knob to twiddle with I'm able to come up with is the part attribute. Try to label the main app .jar with part="main" and the lazy stuff .jar with part="extra".
If you're lucky, the two part collections (main and extra) might get treated differently by Web Start.
See section 4.4 of the jnlp specification for the details.
Regards,
Marc
You should use the part attribute on the jar element, and also use the package element.
But if your code tries to access a resource which is not part of your jar files, JavaWebStart will download all your jar files.
Example.
<jar href="status.jar" part="status download="lazy"/>
<package name="com.acme.status.*" recursive="true" part="status"/>
If you try to get a resource :
com.acme.status.Test.gif, and this is not part of the status jar, Java Web Start WILL download all your jar files, and then look for the resource there.
You can also look at :
http://developer.java.sun.com/developer/bugParade/bugs/4420761.html