Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»JAVA»How to Install Java 11/8 on Amazon Linux

    How to Install Java 11/8 on Amazon Linux

    By RahulOctober 31, 20202 Mins Read

    This tutorial will help you to install Java 11 or Java 8 on the Amazon Linux system. As of now, Oracle has restricted these Java versions for registered users only, we will use OpenJDK for this installation.

    Advertisement

    Step 1 – Install Java on Amazon Linux

    The OpenJDK 8 is available under default yum repositories and OpenJDK 11 is available under Amazon Linux 2 extras repositories. You can simply install Java 11 or Java 8 on the Amazon Linux system using the following commands.

    • Run below commands to install Java 11 on Amazon Linux:
      sudo amazon-linux-extras install java-openjdk11
      
    • Run below commands to install Java 8 on Amazon Linux:
      sudo yum install java-1.8.0-openjdk
      

    Step 2 – Check Active Java Version

    After successfully installing Java on Amazon Linux using the above steps, Let’s verify the installed version using the following command.

    java -version
    
    openjdk version "1.8.0_222"
    OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
    OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
    

    Step 3 – Switch Java Version

    Use alternatives command-line utility to switch active Java version on your Amazon Linux system. Run below command from the command line and select the appropriate Java version to make it default.

    alternatives --config java
    

    Install Java on Amazon Linux

    After switching let’s check again active Java version:

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

    Conclusion

    In this tutorial, you have learned to install Java 11 and Java 8 on Amazon Linux system. You also found instructions to switch between multiple java versions.

    Amazon Linux install java Java Java 11 java 8
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Set JAVA_HOME environment variable on macOS

    How to Set JAVA_HOME environment variable on macOS

    What is the Access Modifiers in Java

    What are the Access Modifiers in Java

    Installing Java on Ubuntu 22.04

    How to Install JAVA on Ubuntu 22.04

    View 13 Comments

    13 Comments

    1. Yuyun Elvis on October 5, 2022 5:18 am

      Thanks immensely, this has actually helped my team out. We are grateful

      Reply
    2. Power on June 1, 2022 8:05 am

      permission denied when i tried to run : alternatives –config java

      Reply
    3. M on February 5, 2022 8:56 am

      PLEASE BE NOTICED : this installation is not installing JDK8, only JRE is installed !!

      Reply
      • dd11 on July 11, 2022 1:08 am

        whats the command for full jdk?

        Reply
        • haikal on August 8, 2022 3:31 am

          for java 8:
          yum install java-1.8.0-openjdk-devel

          not sure with java 11

          Reply
    4. Rakesh on July 25, 2021 9:59 am

      This was helpful, thank you!

      Reply
    5. ravi jagannadh on June 22, 2021 2:59 am

      very helpful, thank you very much

      Reply
    6. Oleg on April 4, 2021 1:22 am

      It installs Open JRE only and not JDK

      javac -version returns nothing

      Reply
    7. Cleiton on March 21, 2021 11:25 pm

      Very helpful, thanks!

      Reply
    8. sachith soorage on January 12, 2021 1:30 pm

      Thanks

      Reply
    9. Luis on October 1, 2020 9:51 pm

      Gracias

      Reply
    10. raksha on June 9, 2020 9:29 am

      Thank you

      Reply
    11. Jim on December 24, 2019 2:58 am

      This is for amazon linux 2, not amazon linux

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Implementing a Linux Server Security Audit: Best Practices and Tools
    • cp Command in Linux (Copy Files Like a Pro)
    • 15 Practical Examples of dd Command in Linux
    • dd Command in Linux (Syntax, Options and Use Cases)
    • Iptables: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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