Java Web Start : Java Glossary
home J words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish 2008-02-22 by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
JAWS: Java Web Start Java Web Start
Sun’s tool for installing Java applications and updates. It can also distribute Applets. Sometimes called JAWS — Java Web Start. They automatically install and hook themselves up to the Java runtime. All you have to do is click an icon with your browser to use them. Note it is called Web Start, two words, not WebStart. Don’t confuse Java Web Start with Solaris Web Start which is an installer for Solaris platform-specific software. Java Web Start makes it easy for users to install Java apps once they have a web start enabled browser, or the web start app installed.

You can think of Java Web Start apps as ordinary apps plus five main extra features:

Tryout Debugging CD Installs
Installing a JAWS Program Where are the Files? Passwords
Opera Persistence Applets vs JAWS vs Applications
What Is JAWS? Detecting Icon
Gotchas Pros Summary
JNLP Cons Books
Applets Sandbox Learning More
Features Signing Links
Shortcuts Recovery

Trying out Java Web Start

If you have Java installed in your browser, and the *.jnlp association set up, you can try out a simple Java Web Start application called SetClock which sets you PC time from an atomic clock on the web.

Installing A Java Web Start Program

First you must have a recent Java installed. Java Web Start is installed automatically when you install the runtime Java JRE.

There are three ways to install a Java Web Start Application:

  1. Click on a jnlp URL href link in your browser like this, or type it in on the address line:
  2. To install or launch without a browser:
    rem launching javaws from the command line:
    javaws http://mindprod.com/webstart/setclock.jnlp
    
    rem launching with additional debug information
    javaws -verbose http://mindprod.com/webstart/setclock.jnlp
    
    rem launching from a local jnlp file on hard disk
    javaws file:///E:/mindprod/webstart/esper.jnlp
    
    rem learning the javaws.exe command line options
    javaws -help
  3. Unfortunately, this third method only works in older JDKs. Start Java Web Start, i.e. javaws.exe, then type or paste in the name of a jnlp reference such as http://mindprod.com/webstart/esper.jnlp into the locate box. For local files you will need the equivalent url, e.g. file://localhost/E:/mindprod/webstart/esper.jnlp or the shorter form: file:///E:/mindprod/webstart/esper.jnlp. Unfortunately starting with JDK 1.5, the javaws.exe no longer has a locate box, so this method is no longer possible.
From then on updates are automatic. For the browser link to work, both the ISP and the browser must have JNLP MIME types configured properly, and the browser must associate JNLP files with Java Web Start.

Opera and Java Web Start

To run Java Web Start with the Opera browser, you need to set up an association between MIME type application/x-java-jnlp-file, file extension jnlp, and application C:\Program Files\java\jre1.6.0_06\bin\javaws.exe. You do this by clicking Tools ⇒ Preferences ⇒ advanced ⇒ downloads ⇒ deselect hide files opened by Opera ⇒ New.

What Is a Java Web Start Application?

Java web start applications don’t require a browser to run, though they can be triggered from a browser. They don’t require an Internet connection to run, though normally would require one to download. Unlike Applets, all application jars are cached on the client and are never automatically discarded. They are a quite different sort of animal from Applets, and are more closely allied to applications. Since they are only downloaded once, they can be just as large as any other Java application, e.g. running from a few K to 25 megabytes. I think of them as a Java application plus a simple installer and automatic update applier. The entire installation is controlled by a short XML text file with the extension *.jnlp.

Some of the terms for Java web Start applications are:

Gotchas

JNLP

Applets

It is also possible to distribute your Applets with JAWS. Then they run without a browser. You need to add an <applet-desc section to your JNLP file.
<applet-desc
    documentBase="http://mindprod.com/applets"
    name="Wassup"
    main-class="com.mindprod.wassup.Wassup"
    width="540"
    height="310">
  <param name="milkshake" value="strawberry" />
  <param name="fruit" value="peach" />
</applet-desc>
The Applet runs in an AppletViewer that ignores showDocument.

Features

For people who have dial-up Internet connections, JAWS is clever. If there is a dial-up connection in progress, it checks for updates, and downloads them if necessary. If there is no connection, is does not dial. It simply uses the old code and checks next time when you are connected for an update.

There are a number of services your Web Start application can use. DownloadService lets you check what is in the cache, and remove items from the cache. FileSaveService lets even unsigned applications write to hard disk though the somewhat clumsy FileSaveService API.

Web Start has features for keeping track of various versions of files and automatically ensuring the users have the most up-to-date files. Unfortunately, the version-based protocol requires special support on the Web server. This support can be provided using servlets, CGI-scripts, or by similar means. You can’t pull it off simply by changing the names of the various jar files you upload to a standard http server. Without a special server, files are downloaded with ordinary HTTP with is not restartable if the download aborts. Sun provides a reference Servlet in the download that implements the JNLP protocol that you could run your server. I have no experience with it.

Web Start is Sun’s specific implementation of JNLP. There are other JNLP projects: the Sitraka Deploy Director, Juniper and OpenJNLP on SourceForge. Fontanus Zydego has an implementation similar to JNLP.

I am not sure which of the above projects are client/server or both.

JNLP leaves this unspecified, but Sun’s Java Web Start reference implementation downloads and applies any updates only after you run a program. This unexpected convention has three advantages:

  1. It avoids making the user wait to do useful work. Most of the time the update is not critical.
  2. It only bothers refreshing programs you actually are actively using.
  3. It does not require unattended access to the Internet to fetch downloads, which would happen if updates were scheduled each evening on all apps, LiveUpdate style.

The disadvantage is if a customer complains about a bug and you fix it, they won’t see the fix the next time they run the program, only the time after that.

The really nice thing about Java Web Start is that it does not put many restrictions on how you code. It is very easy to take and ordinary app or Applet and tack on a JNLP file to make it ready for Java Web Start. You don’t need two have different code bases, one for standalone and one for JAWS. This also protects you in case some day JAWS goes the way of all flesh. You could then easily convert your JAWS back to pure standalone with an optional installer. You can use JAWS as if it were purely an easy-to-use installer for ordinary apps, with automatic updating.

Shortcuts

You can configure JAWS in the Java Control Panel advanced how it handles shortcuts — an optional desktop icon to launch, and an optional menu item to launch your JAWS app. I am having trouble with this feature which used to work fine. I have not yet tracked down what the problem is. In theory, you should be able to put hints in your JNLP file as to which shortcuts you want, and the user can override those hints in the Java Control Panel to either always make the shortcuts, always skip them or always ask. You hint in JNLP with code like this in the <information> section:
<!-- hints for setting up shortcuts -->
<!-- Prefer a shortcut for online operation -->
<shortcut online="true">
  <!-- create desktop shortcut -->
  <desktop/>
  <!-- create menu item for this app under the major heading Esperanto -->
  <menu submenu="Esperanto"/>
</shortcut>
In any case, you can safety delete desktop launch icons or menu items if JAWS created them inappropriately. In JDK 1.5, you can also install or uninstall shortcuts with Start ⇒ Settings ⇒ Control Panel ⇒ Java ⇒ General ⇒ Temporary Internet Files ⇒ Settings ⇒ User ⇒ Application ⇒ right click ⇒ Install Shortcuts. This feature was removed in JDK 1.6.

If you want JAWS to recreate menu and/or desktop shortcuts, delete both the menu item and the desktop icon, then run javaws -viewer on the command line then click the Java Web Start short cut arrow button to create the shortcuts. If either one exists, javaws.exe won’t create the other. It also might not create them where you were expecting, so look around.

To bypass problems, you can also create your own shortcuts and menu items manually. To do that, right click on the desktop ⇒ new ⇒ shortcut. Then select the JRE javaws.exe as the launch program e.g. "C:\Program Files\java\jre1.6.0_06\bin\javaws.exe". Then right click the icon ⇒ properties and add the name of the URL after the name of the javaws.exe launch program e.g. "http://mindprod.com/webstart/affirm.jnlp". Don’t forget the quotes. You can select a better icon, perhaps by looking in places like: C:\Documents and Settings\Administrator.ROEDY\Application Data\Sun\Java\Deployment\cache\javaws\http\Dwww.mindprod.com\P80\DMimages\RB affirm.gif.ico

Then you can right click drag ⇒ copy that desktop icon wherever you want onto your menu.

Debugging

If you type javaws and launch your app, there is a preferences section where you can turn on a java console and console logging to a file. You need the file because the console disappears the instant the app terminates.

Always have your app display the version, and change the version for every compile. Otherwise, you could very easily be debugging an old version in cache and not know it. Redating the JNLP files seems to help flush caches faster.

Check the list of running tasks. Sometimes you will see failed java incarnations hanging on. They need to be manually killed or you need to reboot to get rid of them. They can interfere with your debugging.

Especially during launch failure, check all the tabs of the dialog box for clues to the problem. There is much more information than first meets the eye in the general tab.

Where are the Files?

Java Web Start with JDK 1.5 and Windows 2000 hides your jar files away in a directory with an unwieldy name like: C:\Documents and Settings\Administrator\Application Data\Sun\Java\Deployment\javaws\cache\http\Dwww.songprojector.com\P80\DM~roedy\DMwebstart or C:\Documents and Settings\Administrator\Application Data\Sun\Java\Deployment\javaws\cache\http\Dwww.mindprod.com\P80. This ponderous scheme helps avoid name collisions from different websites, even if they deploy the same application. JAWS renames the files; e.g. cyberview.jar becomes RMcyberview.jar to make them harder to find. It also creates the camouflaging RCCyberview.jar for the corresponding certificate, and RTCyberview.jar for some history of your use of the jar. If your Java WebStart application creates any files without taking measures to place them, they will go into a random directory, whatever happened to be the current directory at the time the program was launched.

In JDK 1.6 with Vista, it caches your Java Web Start files in C:\Users\ userid\AppData\LocalLow\Sun\Java\Deployment\cache\6.0 assigning them names completely unrelated to the application.

You can pass configuring information to your application two ways via the resources/properties section of the JNLP file and by putting information in the jars to be got at with getResource.

Persistence

The Java Web Start java.util.prefs.Preferences on Windows uses the registry to store persistent configuration information for your applications. Check the registry My Computer/HKEY_CURRENT_USER/Software/JavaSoft/Prefs for the entries.

Unsigned applications have to use the Mickey Mouse PersistenceService APIs. Signed applications could use the registry-based Preferences class.

Why not just use regular files that way any sane programmer would? The problem is finding them again the next time you execute. There is no data directory naturally associated with the application. Unless you put them in an absolute location, you at least need some way of recalling the name of the directory where all the data are.

Detecting Java Web Start

You can use JavaScript to detect whether a browser has been configured to understand the JNLP mime type, which is the usual barrier to running JAWS applications. Here is the JavaScript code you need to generate the above display:

You can test your Java Web Start installation with some of

.

What’s Right With Java Web Start

What’s Wrong With Java Web Start

Sandbox

Unsigned JAWS apps work in a restricted environment similar to the unsigned Applet sandbox. Unsigned JAWS apps may print with the user’s permission. Web Start uses the same jar-signing mechanism that Applets use. Java Web Start provides a secure API that enables an application to import and export files from the local disk under the user’s control, much the way they can choose and save files in HTML. Unlike an unsigned Applet, an unsigned JAWS app can read and write its own files without user permission. There is still no way for even a signed JAWS app to find some persistent disk space in an easy way. You ween do write an install class that to ask the user for the name of some directory to use.

If your JAWS app is unsigned it must conform to the following restrictions:

Signing

You normally bundle your Java Web Start application up into signed jars, just as you would a signed Applet. You sign them with same code signing certificate and use the same tool jarsigner.exe. You usually build you apps and create the jars with ant, just as you would any Applet or application.

All jars must be signed with the same certificate. This means you must unpack and resign jars built by somebody else. However, Rogan Dawes the author of WebScarab pointed out a way around that restriction. He discovered that if you have multiple JNLP files, all jars mentioned by each JNLP file must be signed with the same certificate, but different JNLP files can be signed with different certificates. Your master JNLP file includes an auxiliary JNLP file (which references jars signed with a different certificate) by inserting a line like this in the <resources> section:

Conveniently, Java only asks the user to OK the master certificate.

Recovering From Java Web Start Failures

Distributing Java Web Start Apps on CD

I have figured out a kludge to distribute Java Web Start Applications on CD. I use it in The Replicator. The main problem is the codebase parameter in the JNLP file must be absolute and match its actual location. In other words, if the CD is in drive R: then the codebase in the JNLP file must be file://localhost/R:/. If it is drive W: then the JNLP file must contain a codebase parameter file://localhost/W:/. My solution was to automatically generate 26 variants on the JNLP file and put them all on the CD. The user could then wake up Java Web Start and feed it the appropriate URL matching their CD ROM drive letter.

This was a bit confusing for the user, so I wrote a little Windows-only C program to figure out which drive letter is the current drive and then automatically select the correct JNLP file. My kicker C program can’t simply generate a custom JNLP file on the fly since the result has to be on the unwriteable CD along with the jar.

The problem was, my program did not know where javaws.exe was installed so it could not automatically start it up. Prior to JDK 1.5, Javaws.exe does not put itself on the path, and does not put any kicker to itself on the path the way it does for java.exe. So I had to spawn a command processor that understood the *.jnlp extension association. This is command.com for W95/W98 and cmd.exe for NT/W2K/XP/W2K3/Vista. I then added an autorun.inf to kick the whole process off automatically. The main problem with this approach other than that it requires 26 generated JNLP files, is that it works only on Windows. Further, it presumes the association between *.jnlp and javaws.exe is functioning.

Here is the C++ source code for Setup.exe.

Others have tried more sophisticated approaches. The Vamp ( Venus Application Publisher) people have come up with a number of ingenious Rube Goldberg solutions. It is not their fault. Sun has made this needlessly difficult. Unfortunately, the Vampqh download links are now dead to clio, Jes, Celia and Pam.

The proper solution to the CD install problem is for Sun to support codebase="cd". It has to be possible for Apps to redistribute themselves in the field on CD to get past firewalls, and carrying data with them. End users can’t tolerate complicated procedures just to move a downloaded JAWS app to CD. Instead of my suggested codebase="CD" parameter, in JDK 1.5+, Sun implemented this:

javaws -import -codebase file:///R:/appa R:/appa/jnlp/app.jnlp
to allow you to override the codebase on the command line. This is not user friendly for manually typing. No technopeasant has a hope in hell of typing that correctly.

From the end user’s point of view, all he should have to do to is insert a CD containing a JAWS install or update in a CD drive, and double click the icon representing the JNLP file. This should work for any platform, requiring only that a JRE be preinstalled.

For Windows an autorun.inf file should do it normal thing to start the launch, as should the equivalent feature for any other OS.

Alternatively, for a mouseless install, the user should simply have to run javaws R: to start any CD install. He should not even have to spell out the name of the JNLP file.

In a similar way, installing a JRE from CD should be equally painless, perhaps requiring the user to select an icon corresponding to his OS from the CD. Then it would check if an install or update were needed, and at the very least do a sanity check of the install to make sure it was intact and the registry was properly set up.

Then if I had my way, these CDs would be distributed in breakfast cereal boxes with a JAWS game or two to install the latest Java on every home desktop ready for subsequent on-line JAWS installs over even slow phone lines.

Passwords

You can protect a JNLP file from public access by putting the link and jnlp file in a password-protected directory. If you can’t get a browser to access it, you can access it directly from Java Web Start by keying in an url that embeds the userid and password like this where roedy is your userid and sesame is your password.
http://roedy:sesame@mindprod.com/replicator/replicatorreceiverwebsite.jnlp

Applets vs JAWS vs Applications

How do you decide whether to use an Applet or a Java Web Start Application or an app installed with a conventional installer such as InstallAnywhere.
Applets vs JAWS vs Applications
Feature Applets JAWS Applications
Requires browser to run?
Must wait for download every time?
How To Install Just view a page containing the Applet. Just click a button on a page to install the JAWS application. Download and run an install package.
Auto-updating
Digitally Signed Yes, to doing do anything interesting, though simple Applets can be unsigned. usually
Client Prerequisites Requires Java JRE installed on machine and in browser. Requires Java JRE installed on machine. Requires application/x-java-jnlp-file MIME type association to javaws.exe set up in browser. Requires *.jnlp association to javaws.exe The installer can automatically install a JRE for you. The install does not require a functioning JRE on the client to get started.
Server Prerequisites just a vanilla HTTP server to serve web pages and jar files. So no special server side code is needed. requires *.jnlp files be served with application/x-java-jnlp-file MIME type. Ideally you also install the JNLP protocol to serve jar changes more efficiently, though it is not necessary. just a vanilla HTTP server to serve web pages and exe files. So no special server side code is needed.
Ease of Writing Must be designed as an Applet from the start. You can turn any ordinary application into a JAWS one by adding *.jnlp file and perhaps an installer class. Requires an install script for the installer and an expensive install bundler.
User Comfort
Fear Factor
below average. Ironically, MS propaganda has users fearing Applets far more than JavaScript when, in actuality, Java is hundreds of times safer. poor This is how the user normally installs programs. The user can’t tell the install apart from another other install written in C/C++.
File Placement Difficult to find a spot to save your data. Requires signed Applets. You must ask the user then use the Preferences api or the server to persist that choice. JAWS automatically allocates you storage, but gives it an ugly meaningless directory name. You can ask the user where to put files as part of your application installer and use the Preferences api to persist it. You could get at the user.dir property to assign space. User decides directory name as part of the installs, based on a default. The installer leaves notes where to find things for the application.
Start Up Time Applets load in their entirely every time over the web. There is some caching. JAWS only downloads your app when it has changed. However it dithers quite along time deciding if it really reads to download it. Especially if you use native compilation, the start up is quick, however, there is no guarantee you are using the latest version.
Speed of Execution Your Applet must share RAM with a fat RAM-hogging browser. JAWS always works with java.exe Hotspot. With a standalone app, you have the option of AOT compilation for extra speed.
Native Code Using signed Applets is extremely difficult with JNI native code because of the difficulty of getting the DLLs installed suitably on the path. JAWS automatically handles placing JNI DLLs on the path, and selecting the version, e.g. Mac or PC suitable for the current platform. You need to use a third-party installer such as InstallAnywhere to arrange for the right version of the DLLs to installed and the path modified to point to them.

Java Web Start Icon

Java Web Start icon

I commissioned an artist from ahasoft.com to create an icon for Java Web Start. It looks like a winged coffee bean being launched by a spring. It comes in sizes from 16 × 16 to 256 × 256 in png, gif, ico and bmp formats. You may download the entire suite of sizes and formats and use it as you please for any purpose but military.

Summary

I like Java Web Start for the following reasons: The key benefit of Applets is simplicity for the user. The key benefit for Java Web Start is automatic update without having to download the entire program every time. The key benefit of an application installer is you don’t need a working JRE to start.

Books

book_cover recommend book⇒Java Deployment with JNLP and Web Start
 paperback
ISBN10:0-672-32182-3
ISBN13:978-0-672-32182-5
publisher:Sams
published:2001-09-29
by:Mauro Marinilli, Mauro Marinilli
470 pages.
Canadian flag amazon.ca. amazon.com. American flag
Canadian flag chapters.indigo.ca . powells.com American flag
French flag amazon.fr. barnesandnoble.com American flag
German flag amazon.de. amazon.co.uk. UK flag

Learning More

Sun’s JDK Technote Guide on JNLP : available:
The Java Web Start runtime comes bundled with the JDK or JRE:
Sun’s JDK Technote Guide on Java Web Start Developer’s Guide : available:
includes Application Developer’s Guide, Download Servlet Guide, JNLP API Documentation, jardiff tool, jnlp-servlet.jar file and the jnlp.jar file.
Sun’s JDK Technote Guide on JAWS (Java Web Start) : available:
Sun’s JDK Tool Guide to javaws.exe command line : available:
Sun’s JDK Technote Guide on JNLP Syntax : available:
Sun’s JDK Technote Guide on JavaScript and VBScript JAWS Detection : available:

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.16] The information on this page is for non-military use only.
You are visitor number 106,027. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/javawebstart.html J:\mindprod\jgloss\javawebstart.html