Reputation: 673
I've run into a problem when trying to launch a jar file using JNLP. We've previously launched the applet without JNLP without any problems. We want to launch three different jars who are kept in the same directory together with the jnlp file. All jars are downloaded but we see a classNotFoundError as soon as we try to load a class from one of the external jars (i.e the ones that aren't the main one). The application runs until this happens so our main jar seem to execute. The JNLP file looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" href="/jars/file.jnlp">
<information>
<title>Client</title>
<vendor>My Vendor</vendor>
<description>Description</description>
<description kind="short">Desc</description>
<offline-allowed />
</information>
<security>
<all-permissions />
</security>
<resources>
<j2se version="1.6+" />
<jar href="mainJar.jar" main="true" download="eager"/>
<jar href="extJar1.jar" main="false" download="eager"/>
<jar href="extJar2.jar" main="false" download="eager" />
</resources>
<applet-desc
name="MyApp"
main-class="path-to-main-class"
width="1"
height="1">
</applet-desc>
</jnlp>
The applet is then launched from the HTML file like this:
<applet
code="com.mycompany.net.MyMainClass"
name="MyApp"
archive="/jars/extJar1.jar, /jars/extJar2.jar, /jars/mainJar.jar"
id="myId"
width="1"
height="1"
mayscript
alt="The java plugin must be installed.">
<param name="jnlp_href" value="/jars/file.jnlp"/>
Java 1.5 or higher required.
</applet>
I've checked then jnlp with Janela which gives me no errors. It works to run the applet from Eclipse as well as without the jnlp file. It also works to open the jnlp-file from javaws, specifying either the file or the url to the file. That leads me to think it's the html that is incorrect. This is however as far as I got. I've tried launching with the following javascript with same result:
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
id:'myId',
code:'com.mycompany.net.MyMainClass',
width:1,
height:1,
name:"MyApp"
};
var parameters = {
jnlp_href:"/jars/file.jnlp",
archive:"/jars/extJar1.jar, /jars/extJar2.jar, /jars/mainJar.jar",
};
deployJava.runApplet(attributes, parameters, '1.6');
Upvotes: 2
Views: 3836
Reputation: 12882
My JNLPs use external jars, and I defined the codebase="http://example.com/full/path/to/jars/"
as well as href="http://example.com/full/path/to/jars/file.jnlp"
in the <jnlp>
tag.
Edit Try my working example - click the Lancer le planificateur
button to see it in action.
edit2 check out JNLP as a Applet in HTML page to see if Object
rather than Applet
will help.
Upvotes: 0