Wednesday, May 1, 2013

Java Web Start

Creating simple Java Web Start application is quite simple. There are three things we need to do.

1. Create the main class and wrap it in a JAR file. For simplicity sake, the main class extends JFrame that contains a JButton inside a JPanel as shown below:


2. Create a JNLP (Java Network Launch Protocol) file that links to the JAR file.

This file is an xml file and the structure is quite self explanatory. The main things here are the codebase attribute in <jnlp> element and the <jar> tag inside <resources> element. The codebase describes base path for all href in the file, in this case it is the base path to find jnlp.jnlp and jnlp.jar since I put those two files in the same folder. The jnlp.jar contains a main class which is stated in main="true" and main-class="edu.mat.jnlp.Main".


3. Create a HTML file that contains a link to the JNLP file.



Opening the HTML in a browser displays the following screen

Clicking the launch button launches the application as shown below:


 

©2009 Stay the Same | by TNB