Tinkering with the JNLP File

The lesson Deploying Java Web Start Applications includes the statement: "The following table describes the elements and attributes in the sample JNLP file". This statement is not true, because the table does not include the j2se element. However the lesson redeems itself with the following admission:

Note: This table does not include all possible contents of the JNLP file. For more information, see the Java Network Launching Protocol & API Specification (JSR-56).

Quite frankly, the lesson would be as useful if this note (or at least the link) were the only the only content in it.

The answer to my earlier question on the main attribute of the jar element is included in the specs, and it turns out that my "logical" guess was wrong. That line in my jnlp file should in fact read:

<jar href="ActiveMathJA002.jar" main="true"/>

But in fact when I substituted that line, the app still would not run. The error message said the application-desc tag was missing, which it isn't, but it tempts me to remove all the redundant crap, so the file looks as follows:

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for ActiveMath -->

<jnlp spec="1.0+"
codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">
<resources>
<jar href="ActiveMathJA002.jar" main="true"/>
</resources>
<application-desc main-class="AMJFormA002"/>
</jnlp>

That didn't help - same error message. So I'll try a file with one element (besides jnlp and xml):

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for ActiveMath -->

<jnlp spec="1.0+"
codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">
<application-desc main-class="AMJFormA002"/>
</jnlp>

It didn't work, but at least I got a different error. Now it is looking for information title. So I'll try:

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for ActiveMath -->

<jnlp spec="1.0+"
codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">
<application-desc main-class="AMJFormA002"/>
<information>
<title>Active Math Java Test</title>
</information>
</jnlp>

Now it wants vendor:

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for ActiveMath -->

<jnlp spec="1.0+"
codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">
<application-desc main-class="AMJFormA002"/>
<information>
<title>Active Math Java Test</title>
<vendor>Softway Interactive Education</vendor>
</information>
</jnlp>

Now it is looking for application resources - I was expecting that ages ago:

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for ActiveMath -->

<jnlp spec="1.0+"
codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">
<application-desc main-class="AMJFormA002"/>
<information>
<title>Active Math Java Test</title>
<vendor>Softway Interactive Education</vendor>
</information>
<resources>
<jar href="ActiveMathJA002.jar main="AMJFormA002"/>
</resources>
</jnlp>

And now it says it can't find the class file. I must say this is the most extraordinarily temperamental utility, and at this stage I think the effort far outweighs any benefit that I can see. Anyone with half a brain could simply download my jar file and run it from the command line without all this ridiculous palaver.

In desperation I started to compose a post for this forum. The forum is quite clever because if you use the code tags, in preview mode, it colours the text to highlight errors. And this enabled me to spot that I had missed a close quotes in the resources section. Also when I unzipped the jar file from my web folder, I remembered that when I was fiddling with packages, I had put the main class into a custom package. The finished file now became:

<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for ActiveMath -->

<jnlp spec="1.0+"
codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">
<application-desc main-class="AMJFormA002"/>
<information>
<title>Active Math Java Test</title>
<vendor>Softway Interactive Education</vendor>
</information>
<resources>
<jar href="ActiveMathJA002.jar" main="AMJPackA002.AMJFormA002"/>
</resources>
</jnlp>

And it ran.

Comments

Popular posts from this blog

A few notes on JavaScript

Forum Comments on Java Applets

Creating a Custom Swing Component