gpt4 book ai didi

java - WebStart 可以使用 DownloadService 动态加载 jar 吗?

转载 作者:行者123 更新时间:2023-12-01 04:25:39 25 4
gpt4 key购买 nike

我尝试使用以下代码动态加载 jar 资源。

    DownloadService ds; 

try {
ds = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");

// determine if a particular resource is cached
URL url =
new URL("http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar");
boolean cached = ds.isResourceCached(url, "1.0");
// remove the resource from the cache
if (cached) {
ds.removeResource(url, "1.0");
}
// reload the resource into the cache
DownloadServiceListener dsl = ds.getDefaultProgressWindow();
ds.loadResource(url, "1.0", dsl);
} catch (Exception e) {
e.printStackTrace();
}

但是我收到如下错误。

    cache: Create from verifier: JarSigningData{hasOnlySignedEntries=true, hasSingleCodeSource=true, hasMissingSignedEntries=false}
network: Cache: Enable a new CacheEntry: http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar
network: CleanupThread used 1 us
network: Downloaded http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar: C:\Users\Administrator\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\63\774e407f-457c5f64-1.0-
cache: Adding MemoryCache entry: http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar
network: Download Progress: jarsDone: 1
2013-08-30 14:19:53,959 4881 [AWT-EventQueue-2] INFO com.ktnet.pki.multibrowser.dialog.SelectCertificateDlg$10 - MOBILE_PHONE param BOKJIRO;KTNET;null;null;null
security: blacklist: hasBeenModifiedSince 1377837583053 (we have 1377739208656)
network: cache found [URL: http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar, 버전: null] prevalidated=false/0
cache: MemoryCache replacing http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar (refcnt=2). Was: URL: http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar | C:\Users\Administrator\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\63\774e407f-457c5f64-1.0-.idx Now: URL: http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar | C:\Users\Administrator\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\63\774e407f-13638c52.idx
cache: Reading Signers from 4389 http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar | C:\Users\Administrator\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\63\774e407f-13638c52.idx
cache: Done readSigners(http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar)
cache: Read manifest for http://localhost:11090/MultiToolkitDemo/download/ubikey-1.0.2.5.jar: read=72 full=5090
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at sun.plugin2.applet.JNLP2ClassLoader.getAppInfo(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.isTrustedByTrustDecider(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.getTrustedCodeSources(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.strategy(Unknown Source)
at com.sun.deploy.security.CPCallbackHandler$ParentCallback.openClassPathElement(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$1000(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$JarLoader.<init>(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.JNLP2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.ktnet.pki.multibrowser.certificate.infovine.InfovineController.init(InfovineController.java:19)

我认为 AppInfo 丢失了。有没有办法动态插入AppInfo。

顺便说一句,像下面这样在 jnlp 中指定 jar 就可以了。

    <resources>
<j2se version="1.6+" java-vm-args="-Dfile.encoding=UTF-8" />

<jar href="ubikey-1.0.2.5.jar" />

</resources>

最佳答案

Its possibly a bug in java7. Don't know that for sure.

The issue here is that the application won't launch unless we manually clear the cache everytime before clicking the JNLP link in webpage.

Possible solutions are

Try Java 6 or Java 7 u12.

where我发现了这个问题。

关于java - WebStart 可以使用 DownloadService 动态加载 jar 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18526949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com