Question: How to downgrade the Java version which got installed/updated during system patching? The “java” command does not run the JVM that has been installed. Java applications can fail to run if an unexpected Java Runtime Environment is found.
Recent version is – java-1.8.0-openjdk-1.8.0.51-1.b16.el6_7.x86_64
Required version is – java-1.7.0-openjdk-1.7.0.85-2.6.1.3.0.1.el6_7.x86_64
# rpm -qa | grep -i openjdk java-1.8.0-openjdk-1.8.0.51-1.b16.el6_7.x86_64 <<------- Recently installed java-1.6.0-openjdk-1.6.0.34-1.13.6.1.el6_6.x86_64 java-1.8.0-openjdk-headless-1.8.0.51-1.b16.el6_7.x86_64 java-1.7.0-openjdk-1.7.0.85-2.6.1.3.0.1.el6_7.x86_64 <<----------- Required version
Use the command "update-alternatives" to switch openjdk/java version on your CentOS/RHEL server.
1. Verify current version of Java used by the server:
# java -version openjdk version "1.8.0_51" OpenJDK Runtime Environment (build 1.8.0_51-b16) OpenJDK 64-Bit Server VM (build 25.51-b03, mixed mode)
2. Switch to older version of java. In this case 1.7.0.85. The command should be executed with root privilege:
# update-alternatives --config java There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java + 2 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-1.b16.el6_7.x86_64/jre/bin/java <<<<<<< + indicate present version used by server. * indicate auto version used. * 3 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java Enter to keep the current selection[+], or type selection number: 3 <<<<<< Enter required selection number. For jre-1.7 provide 3
3. Verify java version again:
# java -version java version "1.7.0_85" OpenJDK Runtime Environment (rhel-2.6.1.3.0.1.el6_7-x86_64 u85-b01) OpenJDK 64-Bit Server VM (build 24.85-b03, mixed mode)