In this tutorial, How to Install JDK on CentOS step by step. How to switch between JDK 7 and JDK 8?
- Open the terminal and log in as root or you use sudo before each command with another user.
- Working on a Linux system operating: Centos/REHL
Search for JDK on CentOS
You use the command below for search the packages
$ yum search openjdk
The output terminal console as below
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 command “sudo alternatives –config java” to switch for JDK.
How to switch JDK 8 to JDK 7
Thought 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.