Java Web Start

One of the issues you must deal with as a Java programmer is how to make your software available to the people who will be using your work. apps require a Java interpreter, so one must either be included with the app, or users must install an interpreter themselves. The easiest solution is to require that users download and install the Java Runtime Environment from Sun's web site at Regardless of how you deal with the requirement for an interpreter, you distribute an app like any other program, making it available on a CD, website, or some other means. A user must run an installation program to set it up, if one is available, or copy the files and folders manually. Applets are easier to make available, because they can be run by web browsers. There are several drawbacks to offering applets instead of apps, most importantly the default security policy for applets, which makes it impossible for them to read and write data on a user's computer, among other restrictions. Java supports another way to make apps available to users: Java Web Start, a method of downloading and running apps by clicking links on web pages. Java Web Start, which requires the Java Plug-in, offers a way to install and run apps as if they were applets. Here's how it works:

  • A programmer packages an app into a Java Archive file along with a file that uses the Java Network Launching Protocol (JNLP), part of Java Web Start.
  • The file is published on a web server along with a web page that links to that file.
  • A user loads the page with a browser and clicks the link.
  • If the user does not have the Java Runtime Environment, a dialog box opens asking whether it should be downloaded and installed.
  • The Java Runtime Environment installs and runs the program, opening new frames and other interface components like any other app. The program is saved in a cache, so it can be run again later without requiring installation.

To see it in action, visit Sun's Java Web Start site at The Web Start Demos page contains pictures of several Java apps, each with a Launch button you can use to run the app, as shown in Screenshot.

Screenshot Presenting Web Start apps on a web page.

[View full size image]Java ScreenShot

Click the Launch button of one of the apps. If you don't have the Java Runtime Environment yet, a dialog box opens asking whether you would like to download and install it. The runtime environment includes the Java Plug-in, a Java interpreter that adds support for the current version of the language to browsers such as Internet Explorer and Mozilla. The environment can also be used to run apps, whether or not they make use of Java Web Start. When an app is run using Java Web Start, a title screen will be displayed on your computer briefly and the app's graphical user interface will appear. Screenshot shows one of the demo apps offered by Sun, a military strategy game in which three black dots gang up upon a red dot and attempt to keep it from moving into their territory.

Screenshot Running a Java Web Start app.

Java ScreenShot

As you can see in Screenshot, the app looks no different than any of the apps you created during the preceding 16 hours. Unlike applets, which are presented in conjunction with a web page, apps launched with Java Web Start run in their own windows, as if they were run from a command line.

Did you Know?

If you try out the dot game, be advised that the red dot is a lot tougher than he looks, even when outnumbered. I tried it out numerous times during the preparation of this hour of the tutorial, and it took dozens of games over several versions before my black dots finally achieved victory.

One thing that's different about a Java Web Start app is the security that can be offered to users. When an app attempts to do some things such as reading and writing files, the user can be asked for permission. For example, another one of the demo programs is a text editor. When you try to save a file with this app for the first time, the Security Advisory dialog box opens (see Screenshot).

Screenshot Choosing an app's security privileges.

Java ScreenShot

If the user does not permit something, the app will be unable to function fully. The kinds of things that would trigger a security dialog are the same things that are not allowed by default in applets: reading and writing files, loading network resources, and the like. Once an app has been run by Java Web Start, it is stored in a cache, enabling you to run it again later without installation. The only exception is when a new version of the app has become available. In this circumstance, the new version will be downloaded and installed in place of the existing one automatically.