Creating the Web Page That Launches the Application

This chapter includes the following topics:


In order for an application to be launched from a web page via JNLP, the page must include a link to the JNLP file. E.g., to be able to launch application app.jnlp on a web site, the page needs to include the following link:

<a href=>Launch the application</a>

It may be the case, however, that Java Web Start is not installed on the user's computer. Thus the page needs to include logic (scripts) to take account of this. In fact, the page should include logic for the following:

Detect if Java Web Start is installed

The scripts, and the HTML for the auto-install page, are discussed below.

Detecting if Java Web Start is installed on Netscape

Here is the first script that should be run on a web page for launching an application via JNLP:

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";

This script looks at the navigator.mimeTypes object and the navigator.mimeTypes.length var to decide if the browser is Netscape or IE. If length is 0, it is assumed the browser is IE, as with IE the navigator.mimeTypes array is defined but always empty. If length is non-zero, then the browser is assumed to be Netscape and the JNLP MIME type is checked to see if it exists on Netscape. If so, javawsInstalled, javaws142Installed, and javaws150Installed are all set to 1. With Netscape it is not possible to determine which particular version of Java Web Start is installed, so all four variables are set to 1.

Detecting if JavaWeb Start is installed on IE, and if so, the version

The above JavaScript should be followed by a VBScript that sets variables related to Internet Explorer browers:

on error resume next
If isIE = "true" Then
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled"))) Then
     javawsInstalled = 0
     javawsInstalled = 1
  End If
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled."))) Then
     javaws142Installed = 0
     javaws142Installed = 1
  End If 
  If Not(IsObject(CreateObject("JavaWebStart.isInstalled."))) Then
     javaws150Installed = 0
     javaws150Installed = 1
  End If  
End If

This VBScript is executed if the variable isIE from the preceeding JavaScript is "true"; i.e., if the end-user's browser is Internet Explorer. This script instantiates the isInstalled COM object in JavaWebStart.dll, and this object determines four things:

After the above two scripts have been executed, the variables javawsInstalled, javaws142Installed, and javawsInstalled150 will be set to either 1 or 0, as follows:

javawsInstalled javaws142Installed javaws150Installed
Internet Explorer 1 if any version of Java Web Start is installed; 0 otherwise. 1 if Java Web Start 1.4.2 is installed; 0 otherwise. 1 if Java Web Start 1.5.0 is installed; 0 otherwise.
Netscape Navigator 1 if any version of Java Web Start is installed; 0 otherwise. 1 if any version of Java Web Start is installed; 0 otherwise. 1 if any version of Java Web Start is installed; 0 otherwise.

Launching the application if Java Web Start is Installed—or providing a link for auto-install or general download page

An additional JavaScript can be used to decide whether to:

The following JavaScript handles these scenarios:

<script language="JavaScript">
/* 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("<a href=>Launch the application</a>"); } else { document.write("Click "); document.write("<a href= pass= fail=>here</a> "); document.write("to download and install JRE 5.0 and the application."); } </SCRIPT>


  1. The script only uses javawsInstalled—not javaws142Installed or javaws150Installed.
  2. The line breaks following '?' and '&' are for readability purposes only; in an actual script there should be no breaks in the href string.

If javawsInstalled is 1, indicating that Java Web Start is already available on the client, then the script provides a link to the application's jnlp file. If Java Web Start is not installed on the client, the script instead provides a link to the PluginBrowserCheck program on the web site. PluginBrowserCheck checks whether the client uses Internet Explorer on a Microsoft Windows platform. If so, PluginBrowserCheck sends the user to the auto-install page (See the next section, Creating an auto-install page, for how to create an auto-install page for IE running on Windows.) If PluginBrowserCheck determines the user is not using Internet Explorer on Microsoft Windows, the user is redirected to the 5.0 JRE general download page on

Creating an auto-install page

Note: file in the codebase attribute below will not be available until the GA release of the 5.0 JDK/JRE.

For a complete list of JRE releases that can be autodownloaded via a .cab file, as mentioned below, see Autodownload Files (Windows Only).

The download.html file should be staged on the server side. It contains special OBJECT and PARAM tags that will download to the client an auto-installer for JRE 5.0 . Along with Java Web Start, an ActiveX control will be downloaded to the client. The ActiveX control will launch the application using the newly installed Java Web Start. Here is a sample download.html file:

<OBJECT codebase="" 
classid="clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284" height=0 width=0>
<PARAM name="app" value="">
<PARAM name="back" value="true">
<!-- Alternate HTML for browsers which cannot instantiate the object -->
<A href="">
Download Java Web Start</A>

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.

For issues relating to application development see the next chapter, Application Development Considerations.