Installing open jdk 11 on centos using yum commands

Globe Admin picture Globe Admin · Nov 19, 2018 · Viewed 16.8k times · Source

I want to install open jdk 11 using yum command . however when i check the open jdk manual , it says up to jdk version 1.8 you can use yum command . how ever with 9 on wards you have to download zip or tar file . (https://openjdk.java.net/install/)

any reason why we are not provided with a yum command. I am bit newbie to linux. appreciate any help

Answer

Asad Shakeel picture Asad Shakeel · Nov 4, 2020

As per November 2020

you can achieve this in 2 steps

  1. Install the Java 11 using the yum

    yum install java-11-openjdk-devel

  2. Get all the Java configurations available in your machine

    alternatives --config java

    Run the above command, select the version you want to set, I've set 1 here

    There are 2 programs which provide 'java'.
    Selection    Command
    
    -----------------------------------------------
       1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el7_8.x86_64/bin/java)
    *+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin/java)
    
    Enter to keep the current selection[+], or type selection number: 1
    
  3. check java -version

    openjdk version "11.0.8" 2020-07-14 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)
    

The Java 11 is now set to use globally in the machine.