Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»JAVA»How to Install Java on CentOS 8

    How to Install Java on CentOS 8

    RahulBy RahulSeptember 18, 20192 Mins ReadUpdated:June 18, 2020

    This tutorial will help to install Java on CentOS 8 and RHEL 8. Let’s follow the below simple steps for the installation. The Oracle Java 8 and Java 11 required subscription to download and install. So we use OpenJDK for this installation to run Java on CentOS 8 and RHEL 8 Linux system.

    Step 1 – Search Java Packages

    The OpenJDK rpm packages are available under the AppStream repository. Use the following command to search available Java packages under configured DNF repositories.

    sudo dnf search openjdk
    

    Step 2 – Install Java on CentOS 8

    Now, use one of the following commands to install the required Java version on your CentOS 8 and RHEL 8 Linux system. You can also install the both Java version on any system and use as per your requirements.

    Install JAVA 11:

    sudo dnf install java-11-openjdk
    

    Install JAVA 8:

    sudo dnf install java-1.8.0-openjdk
    

    Step 3 – Check Java Version

    I have installed both Java version for this article, First I have installed Java 11 then installed Java 8 on my CentOS 8 system. Let’s check the installed and current active Java version on your system using the following command:

    java -version
    
    openjdk version "1.8.0_222"
    OpenJDK Runtime Environment (build 1.8.0_222-b10)
    OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
    

    Step 4 – Switch Between Java Versions

    You can use alternatives command to switch between multiple Java versions installed on your CentOS 8 and RHEL 8 Linux systems.

    sudo alternatives --config java
    

    A list of installed Java versions will be displayed. Select the appropriate Java version number and press enter. In my case, Java 8 is currently active so I entered 1 in selection to change it to Java 11.

    After change again check the current active Java version.

    java -version
    
    openjdk version "11.0.4" 2019-07-16 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)
    

    Conclusion

    In this tutorial, you have learned about installation of Java 11 and Java 8 on CentOS 8 Linux system.

    CentOS 8 Java Java 11 java 8 RHEL8
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Install Red5 Server on Ubuntu 18.04 & 16.04
    Next Article How to Whitelist an IP in fail2ban on Ubuntu & Debian

    Related Posts

    How to Install JAVA on Ubuntu 22.04

    Updated:May 16, 20224 Mins Read

    Java HashMap – How to Get Value from Key

    Updated:April 6, 20222 Mins Read

    Java HashMap – How to Get Key from Value

    Updated:April 6, 20222 Mins Read

    5 Methods to Print an Array in Java

    Updated:April 21, 20222 Mins Read

    How To Install Java on Debian 11

    4 Mins Read

    How To Install Security Updates on CentOS 8 (Manual + Automatic)

    4 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.