From the author of

From the author of

The first article of this tutorial introduced the JNLP protocol, and
illustrated a simple Java application composed of a single class that shows a
message dialog box onscreen. You can think of any complex Java application
instead, as long as it has a main method to be launched with.

You want to use JNLP to launch and update your applications seamlessly. After
this simple example is discussed, I will introduce other particulars of this
technology.

The JNLP Launching File

The core of the JNLP technology, as discussed in the first article, is the
JNLP file. Indeed, you can have several types of JNLP files, but this article is
limited to the one needed to launch applicationscalled the main
JNLP file. Listing 1 shows the JNLP file that launches the Example
class listed in the previous article.

Line 4 specifies the codebase for your application. This concept
is analogous to the applet.

The information element (lines 614) provide some general
data about your application, such as its title, the company/authors that
provided it, and so on. (You can see how the Java Web Start JNLP Client uses
this information in Figure 3).

Line 9 specifies the application homepage, where users can see some
documentation, help support, and so on.

Lines 1516 don't specify any security value, so the default
value (untrusted) is used. Other possible values are trusted (but you
have to sign with a valid certificate all the JAR files you provide) and the
security level is specified for J2EE clients.

The resources element specifies which files and which
constraints constitute the application. This element is quite rich in features
(you can specify native libraries, native executables to be used, Java optional
packages, locales ,and other constraints). In this case, it informs the JNLP
Client that the application is composed of only one JAR file, and it requires an
installed Java 2 JRE of version 1.3 or newer.

The application-desc element at line 21 says that (1) this JNLP
file is for describing applications, and (2) specifies the main classthe
one with the main method. If you didn't specify the main class, the JNLP
Client would have tried to use the one in the JAR manifest file. If this latter
one didn't exist, the JNLP Client would have issued an error.

Note that the previous example cannot run on a Java 2 JRE of version 1.2 or
older. If a suitable JRE is not already installed, the JNLP Client will try to
download it. Conversely, if a suited JRE is already installed, there is no need
to install a new one. This solves the problem of Java applicationseach one
carrying its own JRE with multiple installations on the same machine.
Furthermore, you can specify an exact JRE (providing an URL), for
example, the IBM 1.4.1 JRE, available at the IBM site you supply.