This post is regarding how to change java version if multiple java versions are installed?

Check what are the java versions are installed on your system

#java -version

Example output

OpenJDK Runtime Environment (build 1.6.0-b09)

OpenJDK Client VM (build 1.6.0-b09, mixed mode)

So now I want to change the one version to another version.

If more than one java is installed. Execute below command to see how many java versions are installed? And what is the default version (Default version will be indicated by *)

#update-alternatives –config java

This command will display which is default java version used by your machine..

Example output.

# update-alternatives –config java

There are 2 programs which provided ‘java’.

Selection Command


1. /usr/lib/jvm/jre-1.4.2-gcj/bin/java

*+ 2 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java

Enter to keep the current selection[+], or type selection number:

So if you want to change the java version from 1.6 (now 2 is default version as shown) to 1.4 just press “1 without quotes.

Please let us know if you know other way of changing java version.