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:
launchWebStartApplication
– Use this function in an HTML link to deploy your Java Web Start application.createWebStartLaunchButtonEx
– Use this function to create a Launch button for your Java Web Start application.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
JNLP file is used to deploy the Dynamic Tree Demo application.dynamictree-webstart-no-codebase.jnlp
<script src="http://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
JNLP file is used to deploy the Dynamic Tree Demo application.dynamictree-webstart-no-codebase.jnlp
<script src="http://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
in a browser to view the Dynamic Tree Demo application that is deployed by using the functions described in this topic.JavaWebStartAppPage_No_Codebase.html
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.