JRE Registry Keys proposal

Draft - 3/10/99 -
Jerome.Dochez@eng









send feedback to dochez@eng

Introduction

In the current JRE and JDK releases, the registry keys are always overwriting themselves which makes impossible for third parties or the Java Plug-in to load a particular JRE it requires. IBM in particular requested to support several 1.1.x JREs on the same machine. Since this problem of multiple JRE's is unlikely to go away in the future (regressions and customer practices) we need to define a set of registry keys that should be defined to support multiple version installed JREs.

The goals of such a proposal is :

The following proposal is concentrating on the new Java 2 Platform naming scheme. The solution describes only the Java 2 Runtime Environment keys. It is left to the imagination of the reader what these keys will look like for the Java 2 SDK.
Current JRE Keys
The current registry keys installed with the JRE 1.2 are as follow :

HKEY_LOCAL_MACHINE\
    JavaSoft\
        Java Runtime Environment\
            CurrentVersion = "1.2"
            1.1\
                JavaHome="c:\Program Files\JavaSoft\JRE\1.1"
                MinorVersion="1.1.7B"
            1.2\
                JavaHome="c:\Program Files\JavaSoft\JRE\1.2.1"
                MinorVersion="1.2.1"
                RuntimeLib="c:\Program Files\JavaSoft\JRE\1.2.1\bin\jvm.dll"

All Java Runtime Environment minor versions (1.2.x) uses the major version (1.2) key overwriting the previous minor version location information.

Proposed Java 2 Runtime Environment keys
In order to insure multiple minor version support, I propose to implement the following registry keys

HKEY_LOCAL_MACHINE\
    Sun Microsystems\
        Java Runtime Environment\
            CurrentVersion = "1.3"
             1.2\
                MinorVersion="1.2.1"
                1.2\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2\bin\jvm.dll"
                1.2.1\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.1"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.1\bin\jvm.dll"
             1.3\
                MinorVersion="1.3.2"
                1.3\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3.2\bin\jvm.dll"
                1.3.1\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3.1"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3.1\bin\jvm.dll"
                1.3.2\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3.2\bin\jvm.dll"

Please note that the company name has been changed from "JavaSoft" to "Sun Microsystems". The product name remains Java Runtime Environment.

Issue: Should we use Java 2 Runtime Environment ? It is absolutely necessary for the name to be independent of the product versioning. When Java 3 Platform is released we cannot change the product keys to Java 3 Runtime Environment. This is why I propose to keep Java Runtime Environment. Please note that this information is never accessed by the user but only by some developers.

Registry Keys Update rules
Now, let's look in detail at the keys installed by one particular Java 2 Runtime Environment installation:

HKEY_LOCAL_MACHINE\
    Sun Microsystems\
         Java Runtime Environment\
           CurrentVersion = "1.2"
             1.2\
             MinorVersion="1.2.1"
                1.2\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2\bin\jvm.dll"

The underlined keys are the keys which are optionally installed. When a Java 2 Runtime Environment installation is about to register its keys, it should check if a previously installed higher version is not already installed and subsequently should never downgrade the current version number.

Example: On my machine I have Java 2 Runtime Environment, Standard Edition 1.3 installed, my registry looks like :

HKEY_LOCAL_MACHINE\
    Sun Microsystems\
         Java Runtime Environment\
             CurrentVersion = "1.3"
             1.3\
                1.3\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3\bin\jvm.dll"

Now I install Java 2 Runtime Environment, Standard Edition 1.2.2, my registry should be updated to

HKEY_LOCAL_MACHINE\
    Sun Microsystems\
         Java Runtime Environment\
            CurrentVersion = "1.3"
            1.2\
                MinorVersion="1.2.2"
                1.2.2\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.2\bin\jvm.dll"
             1.3\
                MinorVersion="1.3"
                1.3\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3\bin\jvm.dll"
 

Now I install Java 2 Runtime Environment, Standard Edition 1.2.1, the registry should be updated to

HKEY_LOCAL_MACHINE\
    Sun Microsystems\
         Java Runtime Environement\
            CurrentVersion = "1.3"
            1.2\
                MinorVersion="1.2.2"
                1.2.1\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.1"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.1\bin\jvm.dll"
                1.2.2\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.2\bin\jvm.dll"
             1.3\
                MinorVersion="1.3"
                1.3\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3\bin\jvm.dll"

Now I install Java 2 Runtime Environment. Standard Edition 1.3.1, the registry should be updated to

HKEY_LOCAL_MACHINE\
    Sun Microsystems\
         Java Runtime Environment\
            CurrentVersion = "1.3"
            1.2\
                MinorVersion="1.2.2"
                1.2.1\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.1"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.1\bin\jvm.dll"
                1.2.2\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.2"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.2\bin\jvm.dll"
             1.3\
                MinorVersion="1.3.1"
                1.3\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3\bin\jvm.dll"
                1.3.1\
                    JavaHome="c:\Program Files\Sun Microsystems\JRE\1.3.1"
                    RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.3.1\bin\jvm.dll"

Registry Keys extraction
Let's look at the steps an application should take to get the appropriate Java 2 Runtime Environment.

Scenario 1 : The application wants the latest Java 2 Runtime Environment.

The Application should get the current major version from :
HKEY_LOCAL_MACHINE\Sun Microsystems\Java Runtime Environment\CurrentVersion

The Application should then get the current minor version from :
HKEY_LOCAL_MACHINE\Sun Microsystems\Java Runtime Environment\X.X\MinorVersion

And then should open the keys at :
HKEY_LOCAL_MACHINE\Sun Microsystems\Java Runtime Environment\X.X\Y.Y.Y
            JavaHome="c:\Program Files\Sun Microsystems\JRE\Y.Y.Y"
            RuntimeLib="c:\Program Files\Sun Microsystems\JRE\Y.Y.Y\bin\jvm.dll"

Scenario 2 : The application require a major version (1.2) but would like to use the latest minor version available.

The Application should get the current minor version from :
HKEY_LOCAL_MACHINE\Sun Microsystems\Java Runtime Environment\1.2\MinorVersion

And then should open the keys at :
HKEY_LOCAL_MACHINE\Sun Microsystems\Java Runtime Environment\1.2\Y.Y.Y
            JavaHome="c:\Program Files\Sun Microsystems\JRE\Y.Y.Y"
            RuntimeLib="c:\Program Files\Sun Microsystems\JRE\Y.Y.Y\bin\jvm.dll"

Scenario 3 : The application require the Java 2 Runtime Environment Standard Edition 1.2.2

The application should open the keys at :
HKEY_LOCAL_MACHINE\Sun Microsystems\Java Runtime Environement\1.2\1.2.2
            JavaHome="c:\Program Files\Sun Microsystems\JRE\1.2.2"
            RuntimeLib="c:\Program Files\Sun Microsystems\JRE\1.2.2\bin\jvm.dll"

Compatibility
It is very clear from this proposal that the new keys are incompatible with the JRE 1.1 and JRE 1.2 keys. Applications that relied on this keys will not be able to load Java 2 Runtime Environment from the "old keys". The main incompatibility is the company name change from JavaSoft to Sun Microsystems. Since this key is the root of all other keys, only that break all efforts to remain compatible.

I would advise that at least for the Java 2 Runtime Environment Standard Edition 1.2 maintenance releases we register both keys (old + new) to start providing version independent hooks for the future and remain compatible for applications relying on the old keys.
 

Command line impact
I would advocate to update the java.exe to be able to a least start any minor version Java 2 Runtime Environment. Since all installations install the java.exe in the shared system directory, the java.exe will by default trigger the last installed JRE.

Issue: Should we update the java.exe with the older version when installing a JRE ? Probably not.

It would be very useful to add an option to the java.exe command to take the desired minor version. The same java.exe could be invoked using the following commands :
    java.exe -Xversion="1.2.1" com.sun.foo.Bar ---> uses Java 2 Runtime Environment 1.2.1
    java.exe -Xversion="1.2.3" com.sun.foo.Bar ---> uses Java 2 Runtime Environment 1.2.3

We could even extend it to support multiple major version for maximum flexibility.