运行java webstart jnlp文件时出现问题

时间:2015-01-28 01:11:14

标签: java java-web-start jnlp

很抱歉这篇文章很长,但我想彻底解决这个问题。其他人已经提出了这个问题,但我相信我遵循了所有发现的here指令,并阅读了已经提出的所有其他问题。下面是jnlp文件内容和html文件(没有真实地址),后面是异常和包装器异常(我确实得到了最新版本的java并验证了它的工作原理)。我是一个相对较新的JNLP和webstart,所以我不确定所有东西是如何组合在一起的。

JNLP内容:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase = "http://example.com/index.html" href="launch.jnlp" spec="1.0+">
    <information>
        <title>Online Time Clock</title>
        <vendor>Kevin</vendor>
        <homepage href="www.google.com"/>
        <description>Online Time Clock</description>
        <description kind="short">Online Time Clock</description>
    </information>
    <update check="always"/>
    <resources>
        <j2se version="1.8+"/>
        <jar eager="true" href="Online_Time_Clock.jar" main="true"/>
    </resources>
    <application-desc main-class="online.time.clock.forms.form">
    </application-desc>
</jnlp>

HTML内容:

 head>
<meta charset="utf-8">
<title>Homepage</title>
<style type="text/css">
@import url("indexcss.css");
#Container2 {
    font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif;
    background-color: #40B169;
    background-image: url(images.jpg);
    background-repeat: repeat;
    letter-spacing: normal;
    text-align: center;
    vertical-align: super;
    word-spacing: normal;
    height: auto;
    width: auto;
    list-style-position: inside;
    list-style-image: none;
    list-style-type: circle;
}
body {
    background-color: #E41114;
    background-image: url(images.jpg);
    background-repeat: repeat;
}
</style>
</head>
<script src="http://java.com/js/deployJava.js"></script>
        <script>
            deployJava.createWebStartLaunchButton("launch.jnlp")
        </script>
<nav>
    <ul>
      <li><a href="#">Home</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Work</a></li>
      <li><a href="#">Places</a>
            <ul>
                <li><a href="#">Someplace</a></li>
                <li><a <a href="launch.jnlp">Launch the application</a></li>
            </ul>
        </li>
      <li><a href="#">Contact</a></li>
    </ul>
</nav>

例外:

com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://50.255.134.177/index.html/launch.jnlp
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.javaws.Launcher.updateFinalLaunchDesc(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.access$000(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

包装异常:

java.io.FileNotFoundException: http://50.255.134.177/index.html/launch.jnlp
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.access$200(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$9.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessController.doPrivileged(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.sun.deploy.net.HttpUtils.followRedirects(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source)
    at com.sun.deploy.net.BasicHttpRequest.doGetRequestEX(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
    at com.sun.deploy.net.DownloadEngine.downloadResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.deploy.cache.ResourceProviderImpl.getResource(Unknown Source)
    at com.sun.javaws.Launcher.updateFinalLaunchDesc(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.access$000(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

1 个答案:

答案 0 :(得分:1)

在你的jnlp文件中,代码库是“http://example.com/index.html”,但代码库必须是目录,而不是文件。相反,你应该有这样的东西:

<jnlp codebase = "http://example.com/" href="launch.jnlp" spec="1.0+">

以上假设你的jnlp在这里:http://example.com/launch.jnlp