Netbeans JNLP Webstart错误

4

我已经为此奋斗了一整天,但我还是无法弄清楚我的错误在哪里。我在NetBeans中创建了一个Web启动页面的项目,按照NetBeans教程的方法进行,但每次我尝试将教程项目或我的项目作为Web启动运行时,都会出现以下错误:

java.lang.NumberFormatException: For input string: "\Users\<snip>"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(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)

我的jnlp文件如下:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/Users/<snip>/dist/" href="launch.jnlp" spec="1.0+">
    <information>
        <title>...</title>
        <vendor>me</vendor>
        <homepage href=""/>
        <description>...</description>
        <description kind="short">...</description>
    </information>
    <update check="background"/>
    <security>
<all-permissions/>
</security>
    <resources>
    <j2se version="1.8+"/>
    <jar eagar="true" href="<snip>.jar" main="true"/>

    </resources>
    <application-desc main-class="<snip>">
    </application-desc>
    </jnlp>

我非常希望能获得这方面的帮助。

1
请务必使用JaNeLA检查JNLP,可在我的共享驱动器上获取。 - Andrew Thompson
由于某种原因,我认为它试图将我的路径设置为整数。 - user
谢谢您的评论,我尝试了一下但仍然遇到了相同的错误。 - user
@user2352274 这只能有两种可能:(1)你没有运行你认为你正在运行的程序(如果你完全删除jnlp中对C:/Users的引用,你就不会得到与它相关的错误),这可能是由于缓存导致的;或者(2)问题出现在你未显示的jnlp文件中... - assylias
为了防止缓存,您可以添加<update check="always" policy="always"/>。此外,我认为在jar部分中不允许使用eagar="true"。您可能是想要使用download="eager"... - assylias
显示剩余3条评论
4个回答

2

将您的jnlp更改为以下内容:

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/MyFolder/" href="launch.jnlp" spec="1.0+">
    <information>
        <title>...</title>
        <vendor>me</vendor>
        <homepage href=""/>
        <description>...</description>
        <description kind="short">...</description>
    </information>
    <update check="background"/>
    <security>
<all-permissions/>
</security>
    <resources>
    <j2se version="1.8+"/>
    <jar eagar="true" href="MyJarFile.jar" main="true"/>

    </resources>
    <application-desc main-class="com.MyCompany.MyMainClass">
    </application-desc>
    </jnlp>

编辑: 如果这不起作用或者您对此有疑问,请在下面添加评论。


当我尝试运行您的代码时,我得到了完全相同的错误,这非常令人困惑,因为我可以通过简单地打开它而不是通过jnlp来运行jar文件。 - user
我确定我的代码出错与你的不同。你的代码出现了这个错误:java.lang.NumberFormatException: For input string: "\ Users<snip>"。但是我的代码中没有出现 <snip> 任何地方。所以请再次尝试我的代码,让我知道你得到了什么样的错误。另外,请注意,无论我在哪里放置 “My…” ,你都应该将其替换为你的文件名。例如,将 MyJarFile.jar 更改为你的 jar 文件的实际名称。 - Saeid Nourian

2

尝试在JNLP-XML中的代码库中加入 file:///C:/Users/snip/dist/

文件URI方案需要2个“/”(file://)。

编辑:
对此没有评论吗?

所以,如果这不起作用,您可以尝试以下操作:
https://dev59.com/RnI-5IYBdhLWcg3wED9V#2417010

其中指出:

<jnlp spec="1.0+" codebase="file://localhost/X:/path/to/jnlp/" href="software.jnlp">

抱歉没有注释,这仍然会抛出相同的错误,我完全感到困惑。 - user

1
请确保您的代码中没有将应用程序路径作为值使用。如果程序接受命令行参数,请尝试在JNLP文件的<application-desc>子元素中指定参数,并直接从命令行运行Java Web Start程序。
javaws path.to.ClassWithMainMethod

0

看起来你的 Web 启动应用程序正在从用户那里获取某种输入。

java.lang.NumberFormatException: For input string: "\Users\<snip>"
at java.lang.NumberFormatException.forInputString(Unknown Source)

根据这行代码,你要求用户输入一个整数,但他们输入了一个字符串或其他内容。
如果你没有使用用户输入,重新安装NetBeans可能会有帮助。
祝好。

我在代码中的某处将日期转换为字符串,但如果我打开jar文件,则我的应用程序可以正常运行,这很奇怪(而且令人烦恼)。 - user
1
实际上,查看堆栈跟踪,可以注意到错误发生在com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx内部,该代码负责验证应用程序的签名。他的代码甚至还没有被调用。 - Haroldo_OK

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接