flipping JVMs : Java Glossary
©1996-2017 Roedy Green of Canadian Mind Products
- 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
seven ways to control which java.exe, javaw.exe, javaws.exe and javac.exe you get.
- Put the
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.
JDK bin program directory :
- Use explicit directory names in all your references to java.exe e.g.
- Use the JAVA_HOME environment variable, or a
Then refer to %JAVA_HOME%\bin\java.exe and %JAVA_HOME%\bin\javac.exe in all your *.bat files.
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.
- 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.
- 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.
- The brute force technique works like this:
- Go into the Control Panel and uninstall all Java
- Go into the registry and wipe all vestiges of HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft.
- Manually wipe all vestiges of the JREs
from hard disk.
- Install the JRE/JDK you want for your test.
- To test with another JRE/JDK, start over at step 1.
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
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.