Step by step Install JDK on CentOS

In this tutorial, How to Install JDK on CentOS step by step. How to switch between JDK 7 and JDK 8?

Precondition

  1. Open the terminal and log in as root or you use sudo before each command with another user.
  2. Working on a Linux system operating: Centos/REHL

Search for JDK on CentOS

You use the command below to search the packages

$ yum search openjdk

The output terminal console as below

Install jdk on Centos step by step

Install JDK 1.8

$ sudo yum install java-1.8.0-openjdk

Confirmation is complete when the installed Java version is displayed.

$ java --version
# Output
# openjdk version "1.8.0_212"
# OpenJDK Runtime Environment (build 1.8.0_212-b04)
# OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

How to switch JDK 7 to JDK 8

Use the command “sudo alternatives –config java” to switch to JDK.

How to switch JDK 7 to JDK 8

How to switch JDK 8 to JDK 7

How to switch JDK 8 to JDK 7

Conclusion

Through the article,  How to Install JDK on CentOS step by step. How to switch between JDK 7 and JDK 8? as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

3 thoughts on “Step by step Install JDK on CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.