创建 Java Applet 异常:缺少;场地
我有点不知所措,试图让我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JNLP 元素应该是:
或者,因为将代码库放在第一位会更常见。
但请确保使用 JaNeLA。它可以比我通过查看 JNLP 更好地检查它。
The JNLP element should be:
or, since it would be more common to have the codebase 1st..
But make sure you validate the JNLP using JaNeLA. It can check a JNLP far better than I can by looking at it.
这似乎是 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.