How to use the Java Web Start CD-Install feature ?

Starting in Java Web Start 5.0, a new import feature is added to javaws command line interface to allow pre-install of application resources into the java web start cache. This can be used for CD installs, where code is initially loaded from one location and then updated from another. It can also be used to pre-install applications and libraries in either the user or system cache without running the application.

Syntax of the import feature:

javaws -import [path to application jnlp file]

This will download the application resources from the jnlp file codebase into the webstart cache.

javaws -codebase [URL of alternate codebase] -import [path to application jnlp file]

This is very similar to the first example, except now application resources are downloaded from the alternate codebase during the import.

With -codebase and -import, you can now create a CD-Installer for your java web start application. Let's take a look at a real life example and see how to do that.

Creating a CD-Installer for the Draw application on java.sun.com:

Originally, the Draw application is hosted on java.sun.com. Its resources include:

http://java.sun.com/products/javawebstart/apps/draw.jar

http://java.sun.com/products/javawebstart/apps/draw.jnlp

http://java.sun.com/products/javawebstart/apps/images/draw.jpg

In the draw.jnlp file, the codebase is set to:

http://java.sun.com/products/javawebstart/apps

To create the CD-Installer for Draw, you want to create a CD with the application resources, e.g, if the cd-rom is drive d, you want to have the following files in the cd:

d:\draw\draw.jnlp

d:\draw\draw.jar

d:\draw\images\draw.jpg

You can then use the following command to install the Draw application from the CD:

javaws -codebase file:/d:/draw -import d:\draw\draw.jnlp

Note: the argument to -codebase must be a URL. file:/d:/draw is the same as file:///d:/draw, which translates to the actual file path d:\draw. file://d:/draw is very different, it will actually tranlates to connect to host d, ftp://d/draw.

It will be more convenient to the end-user if you provide a setup program, so the user can just double-click on the setup program to install the Draw application. As a simple example, here is what you can do in setup.bat:

javaws -codebase file:. -import draw.jnlp

and put setup.bat in:

d:\draw\setup.bat

With this setup, the user can just navigate to the cd-rom directory, and double-click on the setup.bat file, and Java Web Start will do the actual cd-install.

Java Web Start will download the resource from d:\draw into the Web Start cache. The application will be installed as if it were started from java.sun.com (the codebase in the jnlp file). On consecutive launches of the Draw application, Java Web Start will check the original codebase at java.sun.com for available updates.

Silent Import:

During the import, Java Web Start will display the default splash screen, followed by the default progress dialog to show the download progress. You can turn off the progress dialog using the -silent switch:

javaws -silent -codebase file:/d:/draw -import draw.jnlp

You can turn off the splash screen using the -Xnosplash switch:

javaws -Xnosplash -codebase file:/d:/draw -import draw.jnlp

Completely silent:

javaws -Xnosplash -silent -codebase file:/d:/draw -import draw.jnlp

Shortcuts and File association during Silent Import:

You can use the -shortcut or -association switch together with -silent, so web start will automatically create the shortcut or file association (if association is specified in the jnlp file) for the user during the import.

javaws -shortcut -association -silent -codebase file:/d:/draw -import draw.jnlp

If -silent is not specified in the above example, and the application jnlp hints for shortcut/association, java web start will pop up the shortcut/association dialog if the user settings is to prompt.

When -shortcut option is not specified during -silent install, a shortcut will be created only if the application's jnlp file hints for a shortcut, and user's settings allow shortcuts w/o warning dialog.

With -silent -shortcut, a shortcut will be created only if users settings would either popup dialog, or allow w/o dialog.

Same behaviour with file associations.

System Cache Import:

You can import the application into the system cache, so all users on the client can start the application from the system cache. To import into system cache, use the -system switch:

javaws -system -codebase file:/d:/draw -import draw.jnlp

Click here for more information on how to setup the system cache


Last modified: Thu Feb 23 16:02:57 Pacific Standard Time 2006