创建 Java Applet 异常:缺少;场地

发布于 2024-12-26 12:32:56 字数 2007 浏览 5 评论 0原文

我有点不知所措,试图让我的 Java 游戏在浏览器中运行。我已经成功地让它作为 Java Web Start 应用程序运行,但将其转换为浏览器窗口内小程序让我抓狂。

MYAPPLET.jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="MYAPPLET.jar" codebase="http://www.myDomain.com/directoryContainingJar/">
    <information>
        <title>Name</title>
        <vendor>----</vendor>
        <offline-allowed />
    </information>
    <resources>
        <j2se version="1.4+"
             href="http://java.sun.com/products/autodl/j2se" />
        <jar href="MYAPPLET.jar" main="true" />
    </resources>
    <applet-desc 
        name="Name"
        main-class="main.MainClass"
        width="700"
        height="600">
    </applet-desc>
</jnlp>

在我的 html 文件中:

<applet width="700" height="600" code="main.MainClass">
     <param name="jnlp_href" value="MYAPPLET.jnlp">
</applet>

加载页面时出现此错误:

ExitException[ 3]MissingFieldException[ The following required field is missing from the launch file: <jnlp>]
    at sun.plugin2.applet.JNLP2Manager.redirectLaunchDesc(Unknown Source)
    at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
    at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
    at sun.plugin2.main.client.PluginMain.access$300(Unknown Source)
    at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Error while initializing manager: ExitException[ 3]MissingFieldException[ The following required field is missing from the launch file: <jnlp>], bail out

我已更改主类,以便它扩展 JApplet 而不是 JFrame ,但除此之外我不知道该怎么办。

是的,我已经阅读了 http://docs.oracle.com/javase /tutorial/deployment/applet/deployingApplet.html 和 Google 发现了错误。

I'm kinda at my wit's end trying to get my Java game to work in a browser. I've successfully managed to get it to run as a Java Web Start application but converting it to an in-browser-window applet is driving me crazy.

MYAPPLET.jnlp:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp href="MYAPPLET.jar" codebase="http://www.myDomain.com/directoryContainingJar/">
    <information>
        <title>Name</title>
        <vendor>----</vendor>
        <offline-allowed />
    </information>
    <resources>
        <j2se version="1.4+"
             href="http://java.sun.com/products/autodl/j2se" />
        <jar href="MYAPPLET.jar" main="true" />
    </resources>
    <applet-desc 
        name="Name"
        main-class="main.MainClass"
        width="700"
        height="600">
    </applet-desc>
</jnlp>

In my html file:

<applet width="700" height="600" code="main.MainClass">
     <param name="jnlp_href" value="MYAPPLET.jnlp">
</applet>

I get this error when loading the page:

ExitException[ 3]MissingFieldException[ The following required field is missing from the launch file: <jnlp>]
    at sun.plugin2.applet.JNLP2Manager.redirectLaunchDesc(Unknown Source)
    at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
    at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
    at sun.plugin2.main.client.PluginMain.access$300(Unknown Source)
    at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Error while initializing manager: ExitException[ 3]MissingFieldException[ The following required field is missing from the launch file: <jnlp>], bail out

I have changed the main class so that it extends JApplet instead of JFrame but apart from that I don't know what to do.

And yes, I have read http://docs.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html and Google'd the error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱*していゐ 2025-01-02 12:32:56

JNLP 元素应该是:

<jnlp href="MYAPPLET.jnlp" codebase="http://www.myDomain.com/directoryContainingJar/">

或者,因为将代码库放在第一位会更常见。

<jnlp codebase="http://www.myDomain.com/directoryContainingJar/" href="MYAPPLET.jnlp">

但请确保使用 JaNeLA。它可以比我通过查看 JNLP 更好地检查它。

The JNLP element should be:

<jnlp href="MYAPPLET.jnlp" codebase="http://www.myDomain.com/directoryContainingJar/">

or, since it would be more common to have the codebase 1st..

<jnlp codebase="http://www.myDomain.com/directoryContainingJar/" href="MYAPPLET.jnlp">

But make sure you validate the JNLP using JaNeLA. It can check a JNLP far better than I can by looking at it.

茶花眉 2025-01-02 12:32:56

这似乎是 JDK 版本 1.6 update 14 中的错误:http://www.canoo。 com/jira/browse/UBA-8105。你使用什么JDK?尝试使用 JDK 1.7。

This appears to be a bug in JDK version 1.6 update 14: http://www.canoo.com/jira/browse/UBA-8105. What JDK are you using? Try with a JDK 1.7.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文