Q: What's the difference between an application that's Java Web Start enabled and an application that's not? Developers writing Java applications for the Real World (the world outside cozy and manageable corporate networks), must deal with the "ubiquity of Java" problem. While the Java Runtime Environment (JRE) may be very prevalent on most machines in the world (some data puts the number close to 90% of the world's PCs), it is not yet on all machines. And when it is installed, it may use any of several Virtual Machines, from the latest release of Sun's VM to the original Microsoft JVM. How is the developer supposed to widely deploy the application if they do not know which platform to target, or whether that platform will even be available? A developer may write the absolutely coolest, most productive and head-dizzyingly paradigm-shifting productivity application the world has ever seen, but if the intended audience cannot get the thing to run, what is the point? The deployment group at Sun has been looking into this problem and coming up with solutions. In particular, there is one overriding problem that they are trying to solve: Launch a Java application from the browser under a specified version of the JRE. This goal has several implicit problems that have to be resolved:
It turns out that many of these problems have already been solved and are available in Tiger (Java SE), at least for specific browser and platform combinations. The existing solution involves an ActiveX plugin for Internet Explorer (IE) called Auto-Install. With a little JavaScript wrapper and this ActiveX plugin, all of these problems are solved and the application is off and running. And with a little more simple JavaScript code, there is also an easier path to detection and installation for non-Windows/IE browsers and platforms. Let's look at the different pieces that make this work.
Browser Detection
As noted above, the easiest solution that exists today depends on the ActiveX technology of IE. So the first step should be to detect the current browser and platform, with some simple JavaScript code:
Internet Explorer on Windows
If this code detects IE browser on Windows, then the auto-installer technology can be used quite easily. Using it entails simply pointing to the appropriate version of the auto-installer from the java.sun.com download site and passing in parameters that tell it what application to launch when it is ready. The ActiveX component will do the rest.
Some explanation of the above tags might help here:
On some versions of IE, especially those in XP ServicePack 2 and later, the user will be notified that an ActiveX component wishes to be installed and executed. This means the user will have to go through a manual process of accepting this installation before the auto-installer can proceed. Some developers may wish to put helpful text and images on the page to help guide users through this process as appropriate. The OBJECT tag detects if the machine has Java Web Start 1.2 or above installed. If it does, Java Web Start launches and handles the rest of the process (if the JNLP file specifically requests another JRE that is not available on the user's machine, Java Web Start will perform the JRE-autodownload and install). If Java Web Start 1.2 is not available, an install of the latest version of the JRE is needed before the JNLP application is launched; this install and launching is handled by the auto-installer. Once the auto-installer is installed, it executes automatically, detects whether a JRE exists, detects whether the right version exists, and starts an installation if necessary. Once the right version is installed, the auto-installer will finally launch the given application. Observant readers will have noticed that this approach forces an install of one piece of software (auto-installer) in order to detect and install the JRE. Isn't this a tad redundant? Well, yes ... and no. Yes, this process essentially does two separate installs to get the single Java platform the user needs. But the auto-installer piece is quite small and lightweight, and it is quickly downloaded and installed. The auto-installer can then ensure that the user has the right JRE version family installed. Forcing the user through a full install of the appropriate version is a much more heavyweight means of accomplishing the end goal. Also, simply installing the JRE will not automatically launch the application when Java is there; the auto-installer takes care of this piece as well. So apart from the initial step of the user accepting the installation of this ActiveX plugin into the browser, the auto-installer is a much simpler mechanism to get what users need; the application launched using the appropriate version of the JRE. Non-Internet Explorer Browsers
If the JavaScript code detects that the user is not running Internet Explorer, the simple mechanism of the auto-installer is not applicable. What now? In one sense, this is potentially a better situation; there are mechanisms in Mozilla-based browsers that can do some basic Java existence and version detection. These mechanisms may be used to determine that a JRE is already on the platform and does not need to be installed, and the application can simply be launched:
In this example, there is a check of the
Note that a similar check could be run against version 1.4.2 with the string "1.4.2", likewise for other Java versions. Note also that version detection is limited to major (e.g., 1.5) or minor (1.4.2) versions; there is no mechanism for detection of specific update releases. If these means fail and the user either does not have a JRE installed or lacks the appropriate version, it is time to point the user at the download site of java.com and ask them to perform a manual install. This process can be made easier for the user by opening up a new window directed to the download site, and the user can take it from there:
Meanwhile, some more JavaScript code can make the user's life a little easier by continuing to spin and detect whether the JRE is installed yet:
The above code will continually call the Once the
Other Approaches
There are many other detection mechanisms not covered in this article. For example, the IE browser can execute VBScript to detect Java plugin existence (although there are issues with this that may make it more involved than the auto-installer approach above). Applet technology can also be used to detect Java plugin existence and version information; one approach spawns a 1.0-compatible applet to detect the VM version; that information can then be used to spawn another applet of the appropriate version, or to optionally run portions of an applet that take advantage of newer Java features. Summary
The mechanisms above are not flawless; the user can always choose to not install something, or they can close a browser window before the application launches, or they can leave the download page and go somewhere else instead of installing, or other unforseen events can occur. But even so, approaches like those above can make life much easier for both users and developers and make launching Java application much more likely than the more typical approach of simply providing a link to the download site and hoping the user takes the hint. More clever usage of Java detection can lead to more and better Java platform installations overall and better support for launching Java-based applications from the browser. For a complete version of the JavaScript code that uses the approach above, check out this demo. For More Information and Demos
JDK 1.5 Deployment Documentation: More information on the auto-installer, and on browser, platform, and JRE detection. GetJava Logo Program: Use logos and links that send users to the appropriate download site. | |||||||||||||||||||||||
|
| ||||||||||||