How to Install Java 11/8 on Amazon Linux
Abstract: you have learned to install Java 11 and Java 8 on Amazon Linux system. You also found instructions to switch between multiple java versions.we will us
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.
Step 1 – Install Java on Amazon LinuxThe 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
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
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.