开发者

Get JARs under resources within .jnlp file with JNLP API

开发者 https://www.devze.com 2023-03-22 18:30 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消