Reputation: 1003
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.
Upvotes: 3
Views: 5103
Reputation: 168795
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.
Upvotes: 1
Reputation: 15219
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.
Upvotes: 0