Documentation

The Java™ Tutorials
Hide TOC
Deploying Without Codebase
Trail: Deployment
Lesson: Deployment In-Depth
Section: Deployment Toolkit
Subsection: Deploying a Java Web Start Application

Deploying Without Codebase

Beginning in the Java SE 7 release, you do not have to specify an absolute path for the codebase attribute in the Java Web Start application's Java Network Launch Protocol (JNLP) file. You can develop and test your applications in different environments without having to modify the path in the codebase attribute. If no codebase is specified, the Java Web Start software assumes that the codebase is relative to the web page from which the Java Web Start application is launched.

The following functions of the Deployment Toolkit script can be used to deploy Java Web Start applications in a web page when the JNLP file does not contain the codebase attribute:


Note: To run, Java Web Start applications deployed by using the previously specified functions require at least the Java SE 7 release. If the client does not have at least the Java SE 7 release, the functions instruct the user to install the required Java Runtime Environment (JRE) software before launching the Java Web Start application.

Function signature: launchWebStartApplication: function(jnlp)

Parameter:

jnlp – The path to the JNLP file containing deployment information for the Java Web Start application. This path can be relative to the web page in which the Java Web Start application is deployed.

Usage:

In the following example, the launchWebStartApplication function is invoked in the href attribute of an HTML anchor (a) tag.

The dynamictree_webstart_no_codebase.jnlp JNLP file is used to deploy the Dynamic Tree Demo application.

<script src="https://www.java.com/js/deployJava.js"></script>
<a href="javascript:deployJava.launchWebStartApplication('dynamictree_webstart_no_codebase.jnlp');">Launch</a>

The Java Web Start application is launched when the user clicks the resulting HTML link.


Function signature: createWebStartLaunchButtonEx: function(jnlp)

Parameter:

jnlp – The path to the JNLP file containing deployment information for the Java Web Start application. This path can be relative to the web page in which the Java Web Start application is deployed.

Usage:

The following example shows the usage of the createWebStartLaunchButtonEx function.

The dynamictree_webstart_no_codebase.jnlp JNLP file is used to deploy the Dynamic Tree Demo application.

<script src="https://www.java.com/js/deployJava.js"></script>
<script>        
    var jnlpFile = "dynamictree_webstart_no_codebase.jnlp";
    deployJava.createWebStartLaunchButtonEx(jnlpFile);
</script>

The Java Web Start application is launched when the user clicks the resulting Launch button.

Open JavaWebStartAppPage_No_Codebase.html in a browser to view the Dynamic Tree Demo application that is deployed by using the functions described in this topic.


Note: 

You can also launch the Java Web Start application at the system command prompt by invoking the javaws command with the complete url of the JNLP file as shown in the following code snippet.

javaws http://example.com/dynamictree_webstart_no_codebase.jnlp

Download source code for the Dynamic Tree Demo example to experiment further.


Previous page: Changing the Launch Button
Next page: Checking the Client JRE Software Version