Java Web Start
A framework through whichapplications may be executed directly
Java Web Start is a framework through which Java Applications may be executed directly. Applets have limitations - they run within the browser in a restricted area (we had to go through a long process to allow our applet to access local files) and they may take a lot of time to download. Unlike Java applets, applications that use Java web start do not run inside the browser. Java web start applications use configuration files that contain information about the version of JVM and the plug-ins required to run the application. Although JWS applications still run within a restricted sandbox, they may be configured to obtain access permissions from the user through dialogue boxes. Version compatibility between the application and the client machine's JVM is checked and ensured before JWS executes the application. JWS applications do not communicate with Internet Browsers like IE and Firefox as efficiently as Applets. Any Java application (including applets) may be deployed over the web using JWS.
JWS applications may be initiated via a request from an Internet browser. The applications are dispatched to the client machine but are executed outside the scope of the browser. Once a JWS application has been deployed on a user's computer, the application need not be downloaded again. JWS programs do not require re-installation and can automatically download updates. Deploying an application via JWS is quite simple. As an exercise, let us deploy the ShowFruits applet as a JWS application.
Applications usually consist of more than one class - our ShowFruits applet uses three programs - the ShowFruits class, the Fruit class that defines fruit objects and the InputFileFormatException class. Additionally, the thread instance within Showfruits and its inner ImagePanel class also compile into separate class files that start with ShowFruits$<inner_class_reference>. Applications that consist of more than one class are usually packed into a JAR (Java Archive) file - a zip file type compressed format that the JVM understands - for ease of deployment and portability.
Important: Java is case sensitive. Enter all commands with lower and upper case intact in order to avoid errors.
- Create a subfolder called "ShowFruits" in MySamples\src.
- Now, click on start -> run.
- Open a DOS command prompt window - Type 'cmd' in the run dialog box and click OK.
- Issue the following command at the prompt in the MySamples\src subfolder and hit enter:
javac -d ShowFruits ShowFruits.java Fruit.java InputFileFormatException.java

Screenshot 8a: Compiling Applet related classes
- Step 4 stores the class files generated from recompiling the three programs our applet uses into the ShowFruits Directory through the '-d ShowFruits' clause.
- Go to the ShowFruits subfolder and issue the following command:
jar cvf ShowFruits.jar *.class
Screenshot 8b: Creating a jar file
- Now, create a keystore and enter information at the prompts (see screenshot 8c). Remember the password that you will enter for the next step
keytool -genkey -keystore myKeys -alias jdc
Screenshot 8c: Creating a keystore
- The next step involves signing your jar file using the keystore you just created; this will customize your application. You will need to specify your password.
jarsigner -keystore myKeys ShowFruits.jar jdc

Screenshot 8d: Signing ShowFruits.jar
- JWS applications are packaged using JNLP (Java Network Launch protocol). A JNLP file for this application may be found at ShowFruits.jnlp (see screenshot 8e). Change the 'codebase' to reflect the location of ShowFruits.jar and ShowFruits.jnlp on your computer. (codebase="file:///<Location_of_ShowFruits.jar/jnlp_on_your_computer>"). Save this file in the same location as ShowFruits.jar (created during step 6).
Screenshot 8e: A JNLP file
- Now, open the Internet Explorer browser and click File-> Open. Click the "browse" button. Select "All Files" next to "Files of Type" (otherwise, you will only see HTML files). Browse to the directory where you have stored ShowFruits.jnlp and click on ShowFruits.jnlp. Click 'open' and 'ok' to open the file. You will see the following screens, before the applet loads:
Screenshot 8f: Java Web Start Loads Application
Screenshot 8g: Security Appraisal
Note that we did not embed the applet inside an Applet tag within an HTML file. Also, a confirmation window pops up seeking the relevant permissions from the user. Once the applet loads, it will run in a JWS application window outside the browser as follows:

Screenshot 8h: ShowFruits Deployed Using JWS