2009-08-11 86 views
2

這是我第一次嘗試使用Web Start,並試圖啓動我的可運行jar。當我點擊鏈接啓動jar時,我的網頁出現以下錯誤。誰能幫我嗎?本教程中的記事本示例可以在測試頁面上的另一個鏈接上正常工作(JNLP和jar也在我的文件夾中)。 jar和jnlp絕對在同一個文件夾中,但jar無法找到。提前致謝。從Web Start啓動Runnable Jar

文件夾結構:

/MyApp 
/MyApp/MyApp.jnlp 
/MyApp/MyApp.jar 

JNLP文件:

<?xml version="1.0" encoding="utf-8"?> 
<jnlp spec="1.0+" codebase="http://localhost/MyApp" href="MyApp.jnlp"> 
    <information> 
     <title>MyApp Demo</title> 
     <vendor>Company Name</vendor> 
    </information> 
    <resources>  
    <jar href="MyApp.jar"/> 
    <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se"/> 
    </resources> 
    <application-desc main-class="MyAppMain"> 
    <argument>arg1</argument> 
    <argument>arg2</argument> 
    </application-desc> 
</jnlp> 

例外:

com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://localhost/MyApp/MyApp.jar 
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source) 
    at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source) 
    at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source) 
    at com.sun.javaws.Launcher.downloadResources(Unknown Source) 
    at com.sun.javaws.Launcher.prepareLaunchFile(Unknown Source) 
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source) 
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source) 
    at com.sun.javaws.Launcher.launch(Unknown Source) 
    at com.sun.javaws.Main.launchApp(Unknown Source) 
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source) 
    at com.sun.javaws.Main$1.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

包裝異常:

java.io.FileNotFoundException: http://localhost/MyApp/MyApp.jar 
    at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source) 
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source) 
    at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source) 
    at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source) 
    at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source) 
    at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source) 
    at com.sun.javaws.Launcher.downloadResources(Unknown Source) 
    at com.sun.javaws.Launcher.prepareLaunchFile(Unknown Source) 
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source) 
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source) 
    at com.sun.javaws.Launcher.launch(Unknown Source) 
    at com.sun.javaws.Main.launchApp(Unknown Source) 
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source) 
    at com.sun.javaws.Main$1.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: java.io.FileNotFoundException: http://localhost/MyApp/MyApp.jar 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
    at java.net.HttpURLConnection.getResponseCode(Unknown Source) 
    ... 20 more 

控制檯:

Java Web Start 1.6.0_15 
Using JRE version 1.6.0_15-b03 Java HotSpot(TM) Client VM 
User home directory = C:\Documents and Settings\username 
---------------------------------------------------- 
c: clear console window 
f: finalize objects on finalization queue 
g: garbage collect 
h: display this help message 
m: print memory usage 
o: trigger logging 
p: reload proxy configuration 
q: hide console 
r: reload policy configuration 
s: dump system and deployment properties 
t: dump thread list 
v: dump thread stack 
0-5: set trace level to <n> 
---------------------------------------------------- 
#### Java Web Start Error: 
#### Unable to load resource: http://localhost/MyApp/MyApp.jar 

回答

2

我發現我爲什麼這個文件將不會加載振振有辭。這是一個權限錯誤。試圖訪問JAR文件的帳戶沒有Windows權限。我從Eclipse創建了JAR並將其導出到桌面,然後將其複製到JNLP目錄中。複製/粘貼後,這些權限不會更改爲JAR。