BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Upcoming Consumer JRE Seeks to Jumpstart Desktop Java

Upcoming Consumer JRE Seeks to Jumpstart Desktop Java

This item in japanese

At JavaOne, along with JavaFX announcement, Sun's Ethan Nicholas and Denis Gu presented a session providing some details of their work on the consumer JRE that is expected to ship during 2008. "Filthy Rich Clients" author Chet Haase followed up on this with a blog entry on the topic. Not all of the details are available yet, but it is clear that this marks a significant shift of focus within Sun towards the desktop and end user experience, with a great deal of effort going into the Windows version of the JRE in particular.

To address the initial download problem, the Windows version of the Consumer JRE will introduce the Java kernel originally planned for Java 7. This works by fetching the common, essential parts of the Java Runtime such as the Virtual Machine, garbage collector and class-loader, then downloading the other dependencies the application specifies, downloading any "class not found" classes as they are encountered, and then downloading the rest of the JRE in parallel until the entire release exists on the system. To make this work, Sun has needed to make some changes to the way the Java libraries are organized, producing a much smaller rt.jar file and then grouping the missing classes and libraries into components generally along package boundaries. The result is a significant reduction in the amount that needs to be downloaded before an application can start. Limewire, for example, comes down in under 4MB.

The reduction in the physical size of the individual files that make up the Java Runtime may reduce disk seek time a little and thereby help with cold-start up times, but Sun has an altogether more radical solution for reducing the number of times a cold start-up is required. Warm start-up, where portions of Java are already resident in the disk cache, has been reasonable in Java for some time - a typical application taking around 2-3 seconds to launch. However cold start-up can be painfully slow as the OS seeks the various bits it needs in the sometimes very large Java libraries. A common workaround for this (used by applications like QuickTime and Internet Explorer) is to launch the VM into memory on start-up. However if you're not using any Java programs it is something of a waste of RAM and may result in a perception that just installing Java makes a machine run more slowly. The alternative which Sun is pursuing for the Windows Consumer JRE, would be to keep the core Java files in the disk cache. This is done by running a background service which touches the relevant files periodically. In consequence Java applications achieve start-up times comparable to a warm start. The service has a minimal effect on the overall machine performance since, if system memory becomes short, the OS just flushes the disk cache and reclaims memory (as opposed to having to write some pages to the disk before reclaiming as it has to for applications and data in RAM). On a seriously constrained machine the service shuts itself down and leaves the system alone.

To help developers get the right version of Java onto a user's machine Sun is introducing some new JavaScript commands that allow developers to determine which versions of the JRE are installed and prompt users to get a new version if required. The current list is as follows:

  • getJREs() Returns a list of installed JRE versions
  • versionCheck(pattern) Returns true when pattern matches an installed JRE (ex: “1.5*”, “1.6+”)
  • installLatestJRE() Installs the latest JRE using the browser or a “platform appropriate mechanism”
  • writeAppletTag(attributes, parameters) No need to manually write applet tags anymore
  • runApplet(attributes, parameters, version) Ensures appropriate JRE version is installed and then outputs applet tag
  • isWebStartInstalled() Checks if WebStart is installed
  • createWebStartLaunchButton(jnlpURL) Outputs a button that when clicked, ensures webstart is installed and launches the specified JNLP.

So for example the script below will check if JRE 1.5 or higher is installed. If it is the applet will start, if it isn't the user will be asked to download the JRE:

<script>
deployJava.runApplet({code:"Applet.class", archive:"applet.jar", width:320, height:240}, null, “1.5”);
</script>

The script does have some limitations. Specifically it can only detect the highest installed JRE version and can only detect the family version (1.5 rather than 1.5.0_11) but will be available on all the platforms Sun supports. The Windows version of the Consumer JRE will also include browser plug-ins that can perform these functions using native code and thereby get more accurate information. This is handled in a seamless way from a developer point of view - the JavaScript functions simply delegate to the plug-in if it is available.

There are a number of other enhancements. A new Swing cross platform look and feel, Nimbus, has been developed and is covered on InfoQ here. Sun has completely re-written the installer so that it looks a great deal less intimidating than the previous version. There will be a way to access the native FileChooser if you’d rather use it than the Swing FileChooser, and Sun is also hinting that there will be new media components in the Consumer JRE, although the details are currently under wraps.

Rate this Article

Adoption
Style

BT