部署示例Java Web Start应用程序失败。

时间:2013-07-30 06:14:30

标签: java java-ee jar java-web-start

我刚刚开始制作Java Web Start应用程序。我无法在本地正确部署它,因为我一直得到以下异常

我正在关注JWS的以下教程

a)Official Java Documentation

b)Java Web Start (Jnlp) Hello World Example

我做了以下步骤:

1。将我的.class文件打包成可执行jar。

2。签了罐子

3。创建了一个jnlp文件

4。创建了一个html文件

将jar,jnlp和html文件放在同一个JWS目录中并调用html文件。

JWS\

Demo.jar
NewFile.html
Test.jnlp

我的Test.jnlp文件为:

 <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="Test.jnlp">
        <information>
            <title>Jnlp Testing</title>
            <vendor>SUM</vendor>
            <homepage href="http://localhost:8080/" />
            <description>Testing Testing</description>
        </information>
        <security>
            <all-permissions/>
        </security>
        <resources>
            <j2se version="1.6+" />
            <jar href="Demo.jar" />
        </resources>
        <application-desc main-class="com.mytest.TestJnlp" />
    </jnlp>

主要例外:

com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://localhost:8080/Test.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.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.<init>(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.connect(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.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)

好的,所以我能够解决这个问题。

我意识到最简单的入门方法是使用Netbeans IDE。使用Netbeans的优势在于它为制作Java Web应用程序提供了很好的支持。例如,签名罐子并使.jnlp文件配置正确可能是一个真正的痛苦。另一方面,Netbeans会自动生成这两个文件,从而避免了犯错的痛苦。

最初我也试过使用eclipse,但我发现eclipse非常乏味且容易出错。如果制作Java Web Start应用程序,我建议使用Netbeans。本教程应该让您立刻开始。

Enabling Java Web Start in the NetBeans IDE