2011-07-22 53 views
0

有沒有辦法在Java WebStart的.jnlp文件中獲取在<resources>下引用的JAR文件?我認爲JNLP API可以提供幫助,但沒有找到任何方法。有任何想法嗎?使用JNLP API在.jnlp文件內的資源下獲取JARs

例子:

[...] 
<resources> 
    <j2se version="1.6.0+" /> 
    <jar href="../lib/wsfacade.jar"/> 
    <jar href="../lib/resources.jar"/> 
    </resources> 
[...] 

我想要去wsfacade.jar例如路徑,這可能嗎?

從JNLP API

回答

1

的DownloadService2接口可以給你的應用程序的資源:

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()); 
} 

對於參考: