How to Downgrade java version in centos?

Santosh Mohanty picture Santosh Mohanty · Jan 29, 2016 · Viewed 13.3k times · Source

I have installed java in Centos 6.7 with version:

java -version
java version "1.6.0_38"
OpenJDK Runtime Environment (IcedTea6 1.13.10) (rhel-1.13.10.0.el6_7-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

I want to Downgrade the java version to

java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.10) (rhel-1.20.b17.el5-x86_64)
OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

How to achieve this ?

Answer

Thara Perera picture Thara Perera · Sep 8, 2016

Install the version you need ,

# cd /<place you want java installed>/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/<version>/jdk-<version>-linux-x64.tar.gz"

# tar xzf jdk-<version>-linux-x64.tar.gz

Install Java with alternatives,

# cd /<place java install>/jdk1.6.0_17/
# alternatives --install /usr/bin/java java /opt/jdk1.6.0_17/bin/java 2
# alternatives --config java

Then select the version want

There are 2 programs which provide 'java'.

Selection    Command
-----------------------------------------------
* + 1           /opt/jdk1.6.0_38/bin/java
2           /opt/jdk1.6.0_17/bin/java

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

Enter 2