multiple JDKs : Java Glossary

multiple JDKs

Newbies should install only one JDK (Java Development Kit) or JRE (Java Runtime Environment) at a time. You can have several installed, but unless you have very good reason to, don’t, because you will trip over yourself. For most people, you are best off to uninstall your old JDKs and JREs before installing new ones. Then there is no possibility of using a different JRE/JDK from the one you intended.

If you want to install multiple JDK s, first uninstall all your JDKs and JRE s, in order, uninstalling most recent to oldest. Manually delete all the Java directories, and delete all copies of java.exe, javac.exe, javaws.exe etc. you find anywhere on your machine including in C:\Windows\System32. For extra safety delete all the Java registry entries too. Then install the JREs and JDKs the oldest version first and install them in order. If you want the JDK, there in no need to install the corresponding JRE as well. You will get two JREs bundled with the JDK automatically.

Why go to all this work? Sun tests the installs and uninstalls in the order they release the JDKs/JREs. It would be a huge amount of work to test every permutation of orders in install/uninstall of the JDK versions. Further, if a problem were detected, they could not very well modify an old version to correct the problem because many people already have the defective version installed. Old versions have no knowledge of newer versions. To prevent them from inadvertently meddling with newer versions, they should never be installed/uninstalled in the presence of newer version. On the other hand newer versions are aware of the quirks of older versions, so can be safely installed in their presence, especially the version immediately one prior, the most common case.

Then instead of saying java.exe, use the fully qualified name to select which version of the java run time you want e.g. J:\Program Files\java\jdk1.7.0_02 \bin\javac.exe. You an use the Java control panel to select which JRE to use in Java Web Start and in Applets, but not from the command line. Also change set JAVA_HOME J:\Program Files\java\jdk1.7.0_02 to point to the JDK you want to use. Also put J:\Program Files\java\jdk1.7.0_02 on the path.

JAVA_HOME helps Java auxiliary programs like ANT find the JDK. The path lets Windows find the JDK executables you want to use such as javac.exe.

You can also use -source, -target and -bootclasspath to compile with a recent compiler version to approximate what you would have produced with an earlier version.

How Does Java figure out which JDK/JRE to use?

The same principles would probably apply to multiple EE (Enterprise Edition) versions, though I have no experience doing that.

CMP homejump to top You can get the freshest copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/multiplejdks.html J:\mindprod\jgloss\multiplejdks.html
logofeedback Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : feedback email If you want your message kept confidential, not considered for posting, please explicitly specify that.
mindprod.com IP:[65.110.21.43]
view BlogYour face IP:[38.107.179.214]
You are visitor number 11.