Get JARs under resources within .jnlp file with JNLP API
Is there a way to get the JAR files referenced under <resources>
within the .jnlp file of Java WebStart? I thought the JNLP API could help, but didn´t find any method for that. Any ideas?
Example:
[...]
<resources>
<j2se version="1.6.0+" />
<jar href="../lib/wsfacade.jar"/>
<jar href="../lib/resources.jar"/>
</开发者_如何学Goresources>
[...]
I want to get the path to wsfacade.jar for example, is that possible?
The DownloadService2 interface from the JNLP API can give you the resources of the application:
DownloadService2 service = (DownloadService2) ServiceManager.lookup("javax.jnlp.DownloadService2");
ResourceSpec alljars = new ResourceSpec(".*", ".*", DownloadService2.JAR)
ResourceSpec[] results = service.getCachedResources(alljars);
for (ResourceSpec spec : results) {
System.out.println(spec.getUrl());
}
For the reference:
http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/examples.html#DownloadService2
http://download.oracle.com/javase/6/docs/jre/api/javaws/jnlp/javax/jnlp/DownloadService2.html
精彩评论