从Web Start启动Runnable Jar [英] Launch Runnable Jar from Web Start

查看:105
本文介绍了从Web Start启动Runnable Jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试使用Web Start,我正在尝试启动我的runnable jar。当我点击链接启动jar时,我的网页出现以下错误。谁能帮我吗?本教程中的记事本示例可以在测试页面上的其他链接上正常工作(JNLP和jar在同一个文件夹中也是如此)。 jar和jnlp肯定在同一个文件夹中,但是找不到jar。提前致谢。

This is my first time trying to use Web Start, and I am trying to launch my runnable jar. I get the following error from my webpage as I click the link to launch the jar. Can anyone help me out? The Notepad example from the tutorial works fine from another link on the test page (JNLP and jar in same folder as I have too). The jar and jnlp are definitely in the same folder, yet the jar cannot be found. Thanks in advance.

文件夹结构:

/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


推荐答案

我发现这个文件无法加载的原因。这是一个权限错误。尝试访问JAR文件的帐户没有Windows权限。我从Eclipse创建了JAR并将其导出到我的桌面,然后将其复制到JNLP目录中。复制/粘贴后,JAR没有更改这些权限。

I found my reson for why this file will not load. This was a permissions error. The account trying to access the JAR file didnt have windows permissions. I had created the JAR from Eclipse and exported it to my Desktop, then copied it over into the JNLP directory. Those permissions were not changed for the JAR after the copy/paste.

这篇关于从Web Start启动Runnable Jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆