Deploying an application with Java Web Start

© 2012 by W. Patrick Hooper. Licensed under a Creative Commons Attribution 3.0 Unported License.

Purpose: We will create a web start file and explain how to put it on a webpage.


The idea of Java WebStart:

In this tutorial, I've made a program to draw fractal curves.

We've compiled the program and packaged the compiled version of the program into the jar file FractalCurves4.jar using NetBeans (by clicking "Run > Clean and Build Main Project"). ()The compiling and package could also have been done on the command line.)

To run our program, you execute the following command in a terminal from the directory containing the file FractalCurves4.jar.

java -cp FractalCurves4.jar graphics.FractalPathDisplay

So, one way to share your program is to send the .jar file with directions for executing it.

In Java web start, you post the .jar file on your website. You also post a java web start file on your website, which contains the infromation necessary to run your program. They should be in the same directory on your website. For the program above, I posted these files in the following directory.

http://wphooper.com/java/tutorial/source/FractalCurves4/
My jar file is named FractalCurves4.jar and my java web start file is FractalPathDisplay.jnlp. The contents of this java web start file are shown below:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="6.0+"
      codebase="http://wphooper.com/java/tutorial/source/FractalCurves4"
      href="FractalPathDisplay.jnlp">
   <information> 
      <title>Fractal Path Manipulator (ver. 4)</title> 
      <vendor>W. Patrick Hooper</vendor> 
      <homepage href="../../"/>
      <description>Application for playing with fractal curves such as the Highway Dragon generated by polygonal paths substitutions.
This is part of a the Java Tutorial for Mathematics Students by Pat Hooper.</description> <description kind="short">Play with fractal curves</description> <offline-allowed /> </information> <resources> <j2se version="1.6+"/> <jar href="FractalCurves4.jar" main="true" download="eager"/> </resources> <application-desc main-class="graphics.FractalPathDisplay"/> </jnlp>
You should be able to see how to update the above file to your case. You'll need to change the following information: That should be it. The extension of the file should be .jnlp.

Finally, on your webpage just include a link to the .jnlp file. Then someone on your webpage can download the file. If they have Java installed they should be able to run the file by double clicking on the file.

Useful Links


Valid XHTML 1.0 Strict Valid CSS!

This presentation is part of a Mathematical Research Oriented Java Tutorial, which aims to introduce students to the benefits that writing computer programs can provide to their understanding of mathematics.