Distributing an Application using JavaTM
is a technology that allows Java applications
to be launched and installed by clicking a link in a web browser. After clicking the link,
the application will be downloaded to the user's computer. However, Java Web Start keeps track
of the original location of the application, and will automatically download any updated versions
of the program from that location, after the code has been compiled and put in a JAR.
Java Web Start also automates the process of creating Desktop and Start Menu
shortcuts for your application. Java Web Start can also be very useful to programmers, since its
easy deployment and automatic updating simplfy the debugging process. To use Java Web Start,
do the following:
Download Java Web Start.
If you use Java Runtime Environment, v. 1.4.1 or higher
You should already have Java Web Start. Note that the most recent version of Web Start
is only available as part of the Java 1.4.1 JRE, and not as a separate download.
- Create a signed, executable JAR file of your application. Here are our barebones
instructions for creating an executable JAR file and
Create a JNLP (Java Network Launching Protocol) file. This is an XML file that provides Web
Start with some basic information about the program to be executed.
information about the JNLP syntax and
full technical specifications, but we'll provide a summary to get started quickly.
The file name should end with the
.jnlp suffix. Below is an example that shows the basic format.
You can use the file sample.jnlp as a template,
replacing the fields in all capitals with your own values.
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for My Program v1.0 -->
<title>My Program v1.0</title>
<vendor>CS Dept., Princeton University</vendor>
<description>A program I wrote</description>
Explanation of the JNLP elements.
The format is similar to HTML. Each piece of information is enclosed between two "tags" of the form
<tag>...</tag>. Some attributes are placed in quotes within a tag.
In addition, groups of elements are enclosed between tags with names like
"information" and "resources".
- spec: The JNLP version to use -- set it to "1.0+".
- codebase: All relative pathnames in the file will use this as as base (i.e.,
a reference to "productpage.html" will be interpreted as
- href: Reference to the JNLP file
- Information Element
- title: Program name
- vendor: Program Distributor
- homepage: Reference to a page providing more information about the program.
- description (optional): Synopsis of program, to appear on the title screen.
- icon (optional): Icon to be used for shortcuts.
- offline-allowed (optional): If included, allows program to be launched from a downloaded
version if computer is offline or if the connection is slow.
- security: This section contains the <all-permissions> tag, requesting access
to the user's local filesystem.
- Resources element:
- j2se version:Version of the Java Runtime Environment required to run the program.
If you require
any version at or above version 1.x, say "1.x+". For example, "1.2"
is interpreted to mean only 1.2 (nothing higher or lower), but "1.2+"
is interpreted to mean 1.2, 1.3, 1.4, or any other new version.
- jar href:Reference to the executable JAR containing the program.
- application-desc element:
- The main-class attribute should be set to the name of the class file containing
the main function.
- Each of the command-line arguments should be contained between a pair of <argument> tags.
- Finally, create a link to the JNLP file from a webpage. The HTML for this link will look like:
Just click the link, and the program should launch.
The user running your program must also have Java Web Start.
<a href="myprogram.jnlp">Launch My Program</a>
Thomas P. Ventimiglia
Introduction to Computer Science
Last modified: Wed Jul 30 10:33:45 EDT 2003