You can deploy Java Web Start applications by using the
createWebStartLaunchButtonfunction of the Deployment Toolkit script. Java Web Start applications are launched using Java Network Launch Protocol (JNLP) ThecreateWebStartLaunchButtonfunction generates a link (HTML anchor tag -<a>) to the Java Web Start application's JNLP file.This generated anchor tag is the Java Web Start application's
button. When the end user clicks the Launch button, the Deployment Toolkit script ensures that an appropriate Java Runtime Environment (JRE) software is installed and then launches the Java Web Start application.
Note: Depending on the type of browser, you might be unable to view the HTML generated by the Deployment Toolkit script when you try to view the source for the web page. To view the generated HTML, try saving the HTML page after it has been loaded, or use a tool such as Firebug (a Mozilla Firefox add-on).
Note: If the client does not have the required minimum version of the JRE software, the Deployment Toolkit script will redirect the browser to http://www.java.com to allow users to download the latest JRE software.Function signature:
createWebStartLaunchButton: function(jnlp, minimumVersion)orcreateWebStartLaunchButton: function(jnlp)Parameters:
jnlp: The url of the JNLP file containing deployment information for the Java Web Start application. This should be an absolute path.minimumVersion: The minimum version of JRE software required to run this applicationUsage:
- Specifying a minimum version of JRE software that is required to run the application
<script src="http://www.java.com/js/deployJava.js"></script> <script> var url = "http://java.sun.com/javase/technologies/desktop/javawebstart/apps/notepad.jnlp"; deployJava.createWebStartLaunchButton(url, '1.6.0'); </script>
Note: Use thecreateWebStartLaunchButton: function(jnlp)function if your application does not have a minimum JRE software requirement.Note: Running on any JRE software version - Use the
createWebStartLaunchButton: function(jnlp)function if your application does not have a minimum JRE software requirement.- Working around the problem of specifying absolute URL for JNLP file
The requirement of an absolute URL for the JNLP file of a Java Web Start application means that the web page is no longer easily portable to other environments. For example, you have to change the absolute path when you move the application from the development environment to the test or production environment. Applets do not have this problem because applets determine the codebase relative to the page in which they are embedded.You can simulate this behaviour with some JavaScript code, such that the JNLP file's path is relative to the location of the web page from which the Java Web Start application will be launched. See the following sample code:
<script src="http://www.java.com/js/deployJava.js"></script> <script > var dir = location.href.substring(0,location.href.lastIndexOf('/')+1); var url = dir + "notepad.jnlp"; deployJava.createWebStartLaunchButton(url, '1.6.0'); </script>