• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Switch Back To Previous Version of openjdk in CentOS/RHEL

by admin

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)

Filed Under: CentOS/RHEL, CentOS/RHEL 6, CentOS/RHEL 7

Some more articles you might also be interested in …

  1. ‘error opening class fc_host’ – systool Command Error on CentOS/RHEL 7 and 8
  2. tuned-adm and Oracle
  3. How to Configure Persistent Names for Tape Devices in CentOS/RHEL
  4. Patch Management of Linux Servers Using Spacewalk
  5. How to recover GRUB (Corrupted boot partition) in CentOS/RHEL 5,6
  6. How to disable IPv6 on CentOS / RHEL 7
  7. How To Change Engine Database Password for RHVM Engine
  8. How to disable “sudo su” for users in sudoers configuration file
  9. CentOS / RHEL 7 : How to modify the kernel command line
  10. CentOS / RHEL 7 : How to reinstall GRUB2 from rescue mode

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright