Multiple JDK on Windows

If you installed multiple JDKs on windows, here is how to switch among them.

*Create or modify JAVA_HOME environment variable and point it to the correct jdk home.

set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_14
*Add '%JAVA_HOME%\bin' to the beginning of the PATH environment variable.
set PATH=%JAVA_HOME%\bin;%PATH%

*Check correct jdk is now configured by executing DOS command 'java -version'. Make sure that the DOS window is NOT in 'C:\WINDOWS\system32>' since later versions of JDK installation will copy their java executables to that directory so executing 'java -version' in 'C:\WINDOWS\system32>' will always show the version of that java executable.

C:\WINDOWS\system32>cd \
 
C:\>java -version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)
This entry was posted in java, win. Bookmark the permalink.