Web Start

Introduction
Using Java Web Start technology, standalone Java software applications can be deployed with a single click over the network. Java Web Start ensures the most current version of the application will be deployed, as well as the correct version of the Java Runtime Environment (JRE).

Requirements
client: JRE 1.2.2 or higher server: any standard Web Server; new MIME type has to be configured (for .jnlp files)

Configuring the Web Server
The server must return application/x-java-jnlp-file MIME type for JNLP files in order for Java Web Start to be invoked.

Each Web server has a specific way in which to add MIME types. For example, for the Apache Web server you must add the following line to the .mime.types configuration file:

application/x-java-jnlp-file JNLP

General Logic

 * Detect if Java Web Start is installed
 * If so, launch the application.
 * If not, detect if user is running IE on Window.
 * If so, provide link to a page that can auto-install the JRE for Windows
 * If not, provide a link to the general download page for the JDK/JRE.

Some Basic Scripts
<!!-- Detecting if Java Web Start is installed on Netscape -->  var javawsInstalled = 0; var javaws142Installed=0; var javaws150Installed=0; isIE = "false"; if (navigator.mimeTypes && navigator.mimeTypes.length) { x = navigator.mimeTypes['application/x-java-jnlp-file']; if (x) { javawsInstalled = 1; javaws142Installed=1; javaws150Installed=1; } } else { isIE = "true"; } 

<!!-- Detecting if JavaWeb Start is installed on IE, and if so, the version -->  on error resume next If isIE = "true" Then If Not(IsObject(CreateObject("JavaWebStart.isInstalled"))) Then javawsInstalled = 0 Else javawsInstalled = 1 End If If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.4.2.0"))) Then javaws142Installed = 0 Else javaws142Installed = 1 End If  If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.5.0.0"))) Then javaws150Installed = 0 Else javaws150Installed = 1 End If  End If 

An additional JavaScript can be used to decide whether to:


 * provide a link to the application's jnlp file (i.e., Java Web Start is installed);
 * initiate auto-download of JRE 5.0, which includes Java Web Start (i.e., Java Web Start is not installed and the user is running IE on Windows);
 * or provide a link to the general download page for the 5.0 JDK/JRE (i.e., Java Web Start is not installed and the user is not running IE on Windows).

 /* Note that the logic below always launches the JNLP application *if the browser is Gecko based. This is because it is not possible *to detect MIME type application/x-java-jnlp-file on Gecko-based browsers. */ if (javawsInstalled || (navigator.userAgent.indexOf("Gecko") !=-1)) { document.write("Launch        the application"); } else { document.write("Click "); document.write("here "); document.write("to download and install JRE 5.0 and        the application."); } 

Sample auto-install page
      Download Java Web Start</A> </OBJECT> </BODY> </HTML>

This OBJECT tag fetches a .cab file that contains an auto-installer for JRE 5.0. The PARAM tags specify the location of the application's jnlp file so that it may be automatically launched after the JRE is installed on the client.

Application Development Considerations

 * JARs only
 * Java Web Start only transfers JAR files from the Web server to the client machine. It determines where to store the JAR files on the local machine. Thus, an application cannot use disk-relative references to resources such as images and configuration files.
 * All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the Web server. Storing resources in JAR files is recommended, since they will be cached on the local machine by Java Web Start.
 * Icon saveIcon = new ImageIcon(this.getClass.getClassLoader.getResource("images/save.gif"));