Signing the JAR file
Once the JAR files have been created they needs to be signed. This is because a signed JAR file is a requirement for the security permissions needed to load a native library (i.e. any call to System.loadLibrary, which is excatly what the Start class does). The keytool.exe and jarsigner.exe tools are used to create the key and use it to sign the JAR file.
First we create a keystore (a location to hold the keys) using the following command:
keytool -genkey -keystore myKeystore -alias myself
Then we create a self-signed certificate with the following command:
keytool -selfcert -alias myself -keystore myKeystore
Finally we sign the JAR file with the command:
jarsigner -keystore myKeystore myjarfile.jar myself
Creating the JNLP file
The last step is to create the WebStart JNLP file.
Jirrtut1.jnlp source code
The JNLP file is self describing, and you can find more detailed information on the format here. However there are two sections that I will point out.
The first is the <all-permissions> tag in <security>. Requesting all-permissions (which enables the System.loadLibrary function) requires the use of a signed JAR file, and allows the application to load native DLL files.
Second is the <nativelib href="native.jar"> tag in <resources os="Windows">. By referencing the native.jar file in the nativelib tag we are telling WebStart to extract the DLL files contained in native.jar in a location that will be accessible to the System.loadLibrary function.
The end result
Developing a WebStart application does require jumping through a few hoops, but for the most part it allows a Java application to be distributed, downloaded, installed and executed on a client PC with a minimum of fuss for the end user.
Check out the online demo here, browse the source code here, and download the source code in a TAR file here.
Images


Related Articles
Away3D Tutorials
Learn how to add 3D effects to web pages using the Away3D Flash 3D engine with these free tutorials.
3D on the web with Java and Irrlicht
Learn how to use the Irrlicht 3D engine with Java to deliver 3D application via the web.