| # Java Upgrade Guide: Migrating From the Microsoft VM for Java to the Sun JRE |

Search Guide

This guide explains why and how to upgrade applets from the Microsoft Virtual Machine (VM) for Java to the Sun JRE. In 98% of cases, applets run unchanged under the Sun JRE. For the remaining 2%, this document points to migration tips. The results of upgrading should be richly rewarding, as the Microsoft VM is based upon version 1.1, an early, 1997 version of Java technology. The latest, standards-compliant version from Sun Microsystems is 1.4.2. Released in 2003, it includes many enhancements over the early version.

## Why Upgrade?

The Microsoft VM, based upon Java 1.1 technology that is over five years old, is clearly outmoded. On the other hand Sun Microsystem's VM, which is part of Sun's 1.4.2 Java Runtime Environment (JRE), is thoroughly standards compliant and up to date. That makes one good reason for upgrading Java applets and applications to run on the Sun JRE. But there are other compelling reasons: millions of copies of the Sun JRE have already been downloaded and deployed, and millions of new computers will soon be shipping with the Sun JRE. The time is ripe for upgrading.

Another reason to upgrade is that after September, 2004, Microsoft will no longer support or provide a Java implementation with any of its products. Microsoft has already discontinued shipping Java technology in its Internet Explorer web browser with the latest versions of its operating systems. This has two important implications:

- Those running applets in the Internet Explorer web browser will need to download and install an alternate VM.
- In a very few cases, developers will need to modify applets that use proprietary features of the Microsoft VM so they will continue to work.

Note that while Microsoft makes a case for migrating Java applets and applications to J# or C#, neither of these solutions offers cross-platform capability. J# and C# run only on the Microsoft Windows platform.

## How to Upgrade

Here are the steps for upgrading to the Sun JRE:

1. Install the Sun JRE if it is not already installed.
2. Check that your browser uses the Sun JRE and not the old Microsoft VM.
3. Test your applet with the Sun JRE to determine if the applet runs correctly. If the applet doesn't run correctly, find the problem in the list of Potential Upgrade Issues. Click on any issue to see an article that discusses the synopsis, symptom, cause, resolution, and related information, for that issue.

Although most applets run correctly in the Sun JRE, testing is always a good idea. If you should detect an issue, the solution is at hand. Once you have upgraded your applets, they will be able to run on a robust, secure, cross-platform, standards-compliant version of the Java platform.

Once you have confirmed that your applet works properly with the Sun JRE, you may want to consider the best way of deploying the Sun JRE for users. See Internet/Intranet Deployment of the Sun JRE.

## Installing the Sun JRE

If you don't already have the Sun JRE installed on your test computer, click below to get it.

## Checking the VM/JRE

Before you test your applet, you need to make sure that your browser is running the Sun JRE.

To do so, first open the Windows Control Panel (Start > Settings > Control Panel), then double-click the coffee-cup icon labeled Java Plug-in to launch the Java Plug-in Control Panel. When it appears, select the Browser tab. It looks like this:

Make sure that the check box for the browser you are using is checked.

Next, verify that your browser is running the Sun JRE. If it is, when you run the applet you should:

- see the Java icon in the system tray
- initially see the Java icon in the browser window's gray applet-loading box;

Java Icon in System Tray:

Java Logo in Gray Box:

Note: If you have Show Java Console selected in the Java Control Panel, then the Java Console displays and shows a Java version number, as shown in the next section. The version number indicates which Sun JRE is being used by your browser.

## Testing Your Applet

Test your applet by running it. If you have a set of standard tests for it, run it through those tests.

If there is a compatibility issue, you will see details about it in the Java Console. The Java Console looks like this:

For details about the Java Console, see Java Console page.

## Potential Upgrade Issues

Here are some potential issues, listed by symptoms, that you might encounter:

- When running an applet in a browser using the Sun JRE, a `ClassFormatError` is thrown by the `ClassLoader`. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, a `ClassNotFoundException` is thrown by the `ClassLoader`. The same applet runs under Microsoft VM.
- After repackaging the signed `.cab` files as `.jar` files, an applet running in the Sun JRE is treated as unsigned. The same applet packaged as `.cab` files runs as signed in the Microsoft VM.
- After upgrading the signed applet from `.cab` to `.jar` to run in the Sun JRE, the applet no longer works in the Microsoft VM. The applet runs fine in the Sun JRE.
- When running an applet in a browser using Sun's JRE, an `AccessControlException` is thrown in the execution of `Introspector.setBeanInfoSearchPath()` .The same applet runs under the Microsoft VM.
- When running an applet in a browser using Sun JRE, a `ClassNotFoundException` is thrown by the `ClassLoader` on the `com.ms.security` package. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, a `ClassNotFoundException` is thrown by the `ClassLoader` on the `com.ms.*` package. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, deadlock may occur if methods of the applet are over-synchronized, especially those inherited from `java.awt.Component`. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, a `ClassCastException` is thrown from the AWT Dispatch Event Thread when mouse moves over the applet frame. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, a `NullPointerException` is thrown from a thread when `Applet.start()` or `Applet.stop()` is called. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, a `NullPointerException` is thrown in `java.awt.Graphics.drawString()`. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, a `NullPointerException` is thrown in `java.awt.Graphics.drawImage()`. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, an `IllegalArgumentException` is thrown in `java.awt.Color` constructor. The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, an `AccessControlException` is thrown in `stop()`, `suspend()`, or `resume()` of `java.lang.Thread.` The same applet runs under the Microsoft VM.
- When running an applet in a browser using the Sun JRE, an `InstantiationException` is thrown. The same applet runs under the Microsoft VM.
- Unable to use certificates from the browser for client authentication.
- When running an applet in a browser using the Sun JRE, if the applet makes HTTP requests to a server which redirects to an HTTPS URL, the redirection fails. It fails also in the case of making HTTPS requests to a server which redirects to an HTTP URL. The same applet runs without error in the Microsoft VM.
- CJK (Chinese-Japanese-Korean) fonts, when displayed in BOLD, are hard to read.

If you run into an issue not covered in the preceeding list, please see the Java Upgrade Forum:

> http://forum.java.sun.com/forum.jsp?forum=481

###