Tobias
Tobias

Reputation: 7380

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"/>
  </resources>
[...]

I want to get the path to wsfacade.jar for example, is that possible?

Upvotes: 0

Views: 1114

Answers (1)

Emmanuel Bourg
Emmanuel Bourg

Reputation: 10998

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:

Upvotes: 1

Related Questions