About Metamolecular

Metamolecular, LLC builds Web applications and supporting technologies for chemists. We are a privately-held company based in La Jolla, California.

Latest News

Subscribe

Metamolecular Company Blog

Simplifying Java Applet Deployment

Wednesday, November 14, 2007

Given the large number of combinations of Java and browser versions, ensuring a minimum user platform can be less than simple. Recently, Sun introduced the Java Deployment Toolkit to help simplify this task.

In a nutshell, the Deployment Toolkit consists of a set of technologies for simplifying Java deployment, one of which is a JavaScript library containing low-level functions for detecting browser and JDK versions. For example, here are some of the more useful functions:

  • getJREs() - Returns a list of the currently-installed JREs.
  • versionCheck(versionPattern) - Returns true if versionPattern is found. versionPattern can specify a JVM family, exact JVM, or minimal JVM.
  • installJRE(versionPattern) - Performs a platform-specific JVM installation sequence, typically redirecting the user to the Java install Website.

In addition to these low-level functions, higher level functions can be used to simplify the deployment of applets on Web pages. The most useful of these is runApplet(). This function does double-duty. If a JVM version is found (specified by the version parameter), it generates an <applet> tag. If the correct JVM can’t be found, the client is redirected to the Sun Java installation site.

As an example of using runApplet, consider the following, which will run the ChemWriter applet if JDK 1.4.2 or higher is found, or give the user the option of installing the needed JVM.

var attributes = {code:'com.metamolecular.chemwriter.applet.EditorApplet.class',
                  archive:'/applets/chemwriter.jar',
                  width:600, height:300} ;
var parameters = {persistState:false} ;
var version = '1.4.2' ;

if (!deployJava.versionCheck(version+'+'))
{
  if (confirm('To draw structures, you will need to install a newer version of Java. Install Java now?'))
    deployJava.runApplet(attributes, parameters, version);
}

else
{
  deployJava.runApplet(attributes, parameters, version);
}

Additional Java Deployment Toolkit resources can be found here:

The Java Deployment Toolkit may not, out of the box, be the best applet deployment solution in every case. But for those deploying applets in highly heterogeneous computing environments, it could form the basis of a customized solution that will improve both the Java user and developer experience.