• 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. lvresize command examples in Linux
  2. The /var/log/messages is empty, and so are the rotated log files such as messages.0, messages.1
  3. Change default kernel (boot with old kernel) – CentOS/RHEL/OEL 7
  4. RHEL 7 – RHCSA Notes (Cheat Sheets)
  5. Volume “test_vg/lvol0” is not active locally – Error while running lvcreate
  6. How to Delete Duplicate Rules in Routing Policy Database in CentOS/RHEL
  7. How to Log dropped packets using firewalld in CentOS/RHEL 7
  8. How to Rebuild the “initramfs” with Multipath in CentOS/RHEL 6 and 7
  9. How to Install RPM Package During Kickstart Installation
  10. CentOS / RHEL : How to change the UUID of the filesystem

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright