How to change Java Version in Linux?

In this article, you will see how to change default java version to latest version.

Check the current version used on your system.

[root@localhost /]# java -version

Example Output

java version “1.4.2”
gij (GNU libgc) version 4.1.2 2008704 (Red Hat 1.4.2-48)

If there are multiple versions of java, you can change the default version by executing following command. It will also display which is default version used by your machine (indicated by *).

[root@localhost /]#update-alternatives –config java

Example Output

[root@localhost /]#update-alternatives –config java

There are 2 programs which provide ‘java’.

Selection Command

——————————————————————-
*+ 1 /usr/java/jdk1.4.2/jre/bin/java
2 /usr/lib/jvm/jre-1.7.0.-openjdk.x86_64/bin/java

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

Now again check the current version used on your system.

[root@localhost /]# java -version

Example Output

java version “1.7.0_09-icedtea”

,

No comments yet.

Leave a Reply