Java Network Launching Protocol. A protocol for
installing the JVM and Java apps. Sun has written a specific implementation of
it called Java Web Start.
The Java Web Start entry will explain how to set
up the *.jnlp to javaws.exe
association in your browser and desktop.
JNLP Versions
JNLP comes in three versions. 1.0, 1.5 and 6.0.
New in version 1.5, JDK 1.5+:
- splash image type.
- shortcut, associations, related-content
- js2e java-vm-args
- os, arch, and platform
- added ampersand (&) modifier to the version-range argument to allow compound
versions.
New in Version 6.0, JDK 1.6+:
- update and its args check
and policy.
- association now has description
and icon.
- java element to eventually replace j2se.
Sample JNLP 1.5
JNLP (Java Network Launching Protocol) is the
specification. You create an XML specification file, e.g. esper.jnlp
that looks like this:
Sample JNLP 1.6
Here is a sample JNLP 1.6 file:
Note the use of <java instead of <j2se
and <update check="always" policy="always"
/>.
The ordering of the sections matters. You must do them in the order jnlp,
information, security, update,
resources, application-desc, applet-desc,
component-desc, installer-desc.
Within the resources sections, order is again important: java,
j2se, jar, nativelib,
extension, property, package.
You nest <java inside <resources.
However, you can nest another <resources inside the <java
to describe the resources to use for that JVM only.
Icons
Unfortunately Java Web Start, prior to version 1.6, does not support *.png
files for the jnlp <icon image, just *.gif
and *.jpg. *.pngs are
supported in JDK 1.6. It is best to use a 64x64 icon. Unlike *.ico
files, you may not specify multiple resolutions. If you used the *.png
feature, it would cut off the many users still on Java 1.5. There is no support
for *.ico files since they are Windows proprietary, and
JAWS apps are multi-platform. Note that this image is not in the jar. It has to
be downloadable separately before the jar is.
Off/line
If the app needs to be on-line to execute, remove the <offline-allowed/>
from the information section. Beware, some websites erroneously document the
parameter as <allow-offline/>.
JVM Versions
<j2se version="1.3+" /> Does not
mean that JDK version 1.3 or higher will be just fine. It means that any 1.3
version will do except a beta or ea. It does not imply a 1.4 will do. Others
claim it does. I have not performed the experiments. To be safe, I insert
multiple lines like this:
Every time Sun releases a new JRE, you need to add it to all your JNLP files if
you want your clients to be able to access your web start apps with it.
Multiple JNLP files
There are at least two situation where you might use two JNLP files for a single
application:
- When you have an installer. It needs its own separate JNLP file.
- When some jars are signed with one certificate and others with another. You need
an JNLP file for each different certificate and its jars.
You chain the secondary JNLP off the the main JNLP with a line after the <jar:
<extension name="Installer" href="esperinstaller.jnlp"/>
JNLP Validation
You can check that your JNLP file is correctly formed using an XSD Schema
originally from Vampqh. You must copy the JNLP 1.0 XSD schema posted below into
the current directory as file jnlp1.xsd or jnlp6.xsd
then run the Java validation posted below with:
java.exe ValidateJNLP jnlp6.xsd C:\mydir\myapp.jnlp
The XSD Schemas
This JNLP 1.0 schema originaly came from Vampqh. I have modified in slightly.
This JNLP 1.5 schema was mechanically generated by Stylus Studio from the Sun
JNLP DTD. I modified it slightly to allow both an application and installer.
This JNLP 1.6 schema was mechanically generated by Stylus Studio from the Sun
JNLP DTD. I modified it slightly to correct two syntax errors in the DTD and to
allow both an application and installer.
The Validator Program
The above validator is not user friendly. You can get a good idea what it is
looking for by reading the XSD file. It only understands JNLP version 1.0 not
1.5, so it will complain bitterly about your kind="splash"
icons. You can temporarily comment out JNLP 1.5+ features to validate the rest.
You would be surprised how many errors you will find. I am on the lookout for
1.5 and 6.0 XSDs. I may have to compose them myself.
Unfortunately, Vampqh’s fancier validator, Vanessa, is no longer available.
DTD for JNLP
Sun has posted a
and
According to Piotr Kobzda
there
are errors in Sun’s posted JNLP 6.0 DTD, and Andrew Thompson
concurs.
<!ELEMENT update>
should be:
<!ELEMENT update EMPTY>
and
<!ELEMENT shortcut (desktop? menu?)>
should be:
<!ELEMENT shortcut (desktop?, menu?)>
Snooping
One way to learn JNLP tricks is to snoop on the JNLP files of other people’s
applications. You can do that most easily by typing at the command prompt:
javaws.exe -viewer
Learning More
Sun’s JDK Technote Guide on
JNLP syntax : available: