Java: How to set Java version

With java -version at command prompt you can see which java version you are running:

>java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)

If you want to change the java version you should download the appropriate version and declare its existence with the following steps:

JAVA_HOME environment variable (My Computer > Properties > Advanced for windows) should be like:

JAVA_HOME=C:\Program Files\Java\jre1.6.0_05

PATH environment variable should be like:

Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;%JAVA_HOME%\bin;
Note: In PATH environment variable, if you want to declare .jar libraries you must put their full path-file name.
In case you want to include some classes, the file-path they exist is enough.

Optionally you can change the Registry Keys:

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\CurrentVersion
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion

Leave a Reply