Managing two Java versions (Windows)

Ever had a problem of working with two Java versions ? Well this post will explain the basic steps of switching between two or more Java versions that is currently installed on your Windows machine.

When installing Java on your Windows machine it will

  • Add/overwrite specific registry keys
  • Add/overwrite relevant exe’s to system (system32)
  • Environment variables (sometimes this we have to manually if we are installing the second Java version on same machine that has another version of Java already installed)

These approaches will change/modify both Java run-time and JDK on a machine. So when we are switching between different Java versions we have to change these locations by manually or using an automated way. In this post I will only explain the manual approach.

Now I assume you may have already installed a one Java version on your machine so go to the below link and download the latest Java version (current latest version is Java 7)

When you visit the above link you will see they have listed different versions of Java on the table titled as Java Platform, Standard Edition. Download the JDK version (it will also provides the JRE) relevant to your system arch type either 64bit version on 32 bit version. After downloading JDK (ie:  jdk-7-windows-i586.exe) you can now install the Java on your machine. Likewise you can download and install many Java versions on a single machine. Now lets see how you can switch or change a Java version.

First go to the installation location of you all Java versions.


F:\Softwares\Java\jdk1.6.0  – for Java 6                                                                                                                                                  F:\Softwares\Java\jdk1.7.0 – for Java 7

Before you do any changes lets check the current Java version. Open your command line (or cmd) and type java -version.It will give you a output similar to this.

java version “1.6.0_20”
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

of so it’s Java 6 now we want to switch to Java 7

go to bin folder of your Java installation which you are going to switch (Java 7)

F:\Softwares\Java\jdk1.7.0\jdk1.7.0\bin ——– now location three exe files mentioned below.

  1. java.exe
  2. javaw.exe
  3. javaws.exe

copy these three exe files to your Windows system32 folder.


if it asks to overwrite go ahead and do it. Ok now the Java 7 run-time is successfully inserted in to our system but before we proceed we need to another small change to our Windows registry. That change will tell system to use Java 7 as the current system run-time (which is located in system32).

To change the relevant registry key you need an Administrative privileges so make sure you log in as an Administrator of a system. Now go to the registry editor simply type regedit on you run program application. Now location the key

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion

You may see current version as 1.6 modify it to 1.7. That’s it now you are almost done you can now check the Java version again now it says.

java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

Yes, it has changed to Java 7 the hard part is over now. You can now change the Windows environment variables to use JDK on your machine just like you did before with your previous Java version. Now if you want to switch back again to Java 6 you can follow the same steps mentioned above.

As you can see there’s a bit of hassle when you have to change the Windows registry and copying exe files all by yourself. So you can always go ahead and write a Windows batch process or a simple C/C++ script to automate these steps.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s