flipping JVMs : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

flipping JVMs
If you value your sanity, never install more than one JVM (Java Virtual Machine) on a machine at a time. However, you may be forced into doing it. How do you flip back and forth between the different versions of the JDK/JREs?

Changing Command Line java.exe, javaw.exe javaws.exe and javac.exe

There are seven ways to control which java.exe, javaw.exe, javaws.exe and javac.exe you get.
  1. Put the 
    JDK bin program directory :
    as the very first thing on the path even before C:\WINNT\system32\. To change the path, click Control Panel ⇒ system ⇒ advanced ⇒ environment ⇒ path ⇒ edit. Your changes won’t take effect until you start a new DOS (Disk Operating System) box. This will also switch which javac.exe you get.
  2. Use explicit directory names in all your references to java.exe e.g.
    java.exe :
    and
    javac.exe :
  3. Use the JAVA_HOME environment variable, or a temporary override:
    SET JAVAHOME=%JDK
    Then refer to %JAVA_HOME%\bin\java.exe and %JAVA_HOME%\bin\javac.exe in all your *.bat files.
  4. Capture and restore the state of the registry and the C:\WINNT\system32\ files. The idea is you capture the state of a JVM just after it is installed. You can the get back there, no matter what strange stuff has happened to the files or the registry. Once you have captured various configurations, you can restore whichever one you want. This is good protection even if you don’t plan to switch JVMs (Java Virtual Machines) on the fly.

    The key is, to run a version of the JVM, the registry must be set up to point to it and its java.exe, javaw.exe and javaws.exe must be in the C:\winnt\system32 directory as the first version encountered on the path. They can then use the registry to find the other related files.

  5. Write a program to fiddle the registry entries and copy the appropriate java.exe, javaw.exe and javaws.exe to C:\winnt\system32 where they will be the first copies visible on the path. However, even this won’t work for JDK (Java Development Kit) 1.5. When its Java.exe sees the registry set up for 1.4 it aborts.
  6. Use the Java version 1.5 Control Panel ⇒ Java to select which JRE (Java Runtime Environment) you wish to use. For it to work, you should install your JREs (Java Runtime Environments) and JDKs (Java Development Kits) in chronological order. The catch is the fool think hardly ever works properly.
  7. The brute force technique works like this:
    1. Go into the Control Panel and uninstall all Java JREs and JDKs.
    2. Go into the registry and wipe all vestiges of HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft.
    3. Manually wipe all vestiges of the JREs and JDKs from hard disk.
    4. Install the JRE/JDK you want for your test.
    5. Test.
    6. To test with another JRE/JDK, start over at step 1.

Verifying

Verify
java.exe -version
Use javac.exe -version to verify you have the version of the compiler you thought you did. javaw.exe and javaws.exe don’t have a -version option, but once you get java.exe working the others are usually correct to. Unfortunately, older JDK Javac.exe does not support -version. I asked Sun to add support for it and they did.

Controlling the JRE for your Browser

In theory, you should be able to use click Control Panel ⇒ Java and select which JVM of the ones installed you want to use in your browsers. Unfortunately, I have found it usually does not work. Installing a new Java often makes the others become invisible. You can also turn Java support on and off for each browser. If the browser can’t see Java, click Control Panel ⇒ Java, Click browser support off, click apply, click browser support on again, then click apply.

I have found Opera will use the latest JVM installed, then later flip to track to the Java console when you turn off support for IE (Internet Explorer) and Mozilla and then turn it back on again.

In Internet Explorer, you enable Java with: Tools ⇒ Internet Options ⇒ Advanced ⇒ Java Sun ⇒ Use Java (pick JRE).

Controlling the JRE for Java Web Start

You control which version of javaws.exe as for java.exe, however, the Java Web Start app itself uses the JNLP (Java Network Launching Protocol) file to request which version of the JVM it prefers. It automatically selects the best of what you have available where the JNLP file defines best.

This page is posted
on the web at:

http://mindprod.com/jgloss/flipping.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\flipping.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[3.137.214.16]
You are visitor number