Sunday, January 25, 2009

Creating the JNLP File

This lesson is a subsection of the Deploying Java Web Start Applications lesson begun 2 blogs ago, and it continues to be as brilliantly written. It begins with an example. Examples are nice, but in most teaching traditions they are used to illustrate lessons already learnt from first principles. Sometimes they are posted early in a lesson to stimulate thought, and then referred back to as the the lesson unfolds to explain the principles applied in the example. In this case, there is actually no lesson, before or after the example. Instead there is simply a list of elements and attributes. It reminds me of the user manual for MS BasicA, which was published in 1982. I thought user documentation had progressed since then, but obviously not here.

It is hard to believe this is the same tutorial which used a screen shot to explain how to save a text file. Now we are left to reverse engineer a fiddly piece of code, with lots of redundant or superfluous tags, and translate it into something which applies to one's own code.

I personally have no experience manually coding anything in XML. I followed the web quite closely when it first began, and read up thoroughly HTML1 and HTML2, but after that, tools like Fireworks and FrontPage made it unnecessary for to keep pace with developments in the raw code of the web. GUI tools also introduce artists into the field of web development, and I ducked out.

The code in the example is therefore pretty unfamiliar to me and I shall look at it a line at a time. And the first line is no exception:

<?xml version="1.0" encoding="utf-8"?> 

I have no idea why the tag is surrounded by question marks, but there is nothing specific to the notepad app, so I shall cut and paste it in its entirety. The next line is a comment, and could be left out, or modified for ones own app:

<!-- JNLP File for ActiveMath --> 

The next line frankly looks recursive, because it posts a link to itself, but I guess for me it translates as follows:

<jnlp spec="1.0+"codebase="http://202.65.70.207/myweb/"
href="AMJ002.jnlp">

Then there is a whole section called information. I am sure this could be left out altogether, but I'll stick in an amended version for fun:

   <information>     
<title> Active Math Java Test</title>
<vendor> Softway Interactive Education</vendor>
<description> Active Math Java Test</description>
<homepage href="http://202.65.70.207/myweb/index.htm"/>
<description kind="short">
ClickMeApp uses 1 custom class plus one
standard one</description>
<offline-allowed/>
</information>

The next section called resources contains a line I don't understand. The first line is simple enough. It simply points to the jar file and becomes:

<jar href="ActiveMathJA002.jar"/> 

But the second one points to a directory on Sun's server. Do I use that, or do I use the j2se folder on my computer? I can't find a j2se folder on my computer, so I'll leave the URL pointing at Sun:

<j2se version="1.6+"
href="http://java.sun.com/products/autodl/j2se"/>

Finally there is a tag defining the main class in the applet, which in my case becomes:

<application-desc main-class="AMJFormA002"/> 


No comments: