0

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

我正在关注以下 JWS 教程

a)官方 Java 文档

b) Java Web Start (Jnlp) Hello World 示例

我做了以下步骤:

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)
4

1 回答 1

-1

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

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

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

在 NetBeans IDE 中启用 Java Web Start

于 2013-07-31T08:56:36.340 回答