dynamic loading of resources
843802Jul 8 2003 — edited Jul 10 2003Hello.
I am working on an application consisting of two jar files. I want only one of the two jar files to be downloaded onto the user's machine when she first refers to the jnlp file. I tried accomplishing this by the following code in my jnlp file:
<resources>
<j2se version="1.2+" />
<jar href="required.jar" download="eager"//>
<jar href="optional.jar" download="lazy"/>
</resources>
Then, I try to use the DownloadService Interface from jnlp library to dynamically load optional.jar, and the classes contained in it, using code such as this:
DownloadService ds = (DownloadService)ServiceManager.lookup
("javax.jnlp.DownloadService");
ds.loadResource( new URL("http://www.si.umich.edu/IGD/new/tutorials.jar"), null,
new DownloadServiceListener() {...} );
Unfortunately, this doesn't work in several ways:
1. Often when I point my browser to the jnlp file, JWS tries to download both jar files.
2. ds.loadResource doesn't seem to have any effect whatsoever (no downloading window, nothing of the sort). The resource associated with optional.jar seems to always be loaded into the cache, no matter what I do.
3. Despite the fact the optional.jar seems to be loaded into cache, I fail to find the classes that are supposed to be in it, via code such as this:
ClassLoader cl = this.getClass().getClassLoader();
Class tutorialClass = cl.loadClass ("ClassInOptional");
What am I doing wrong? Thanks very much in advance for any advice you could give.
Misha