Another option might be running the following commands:

In order to install java 11:

sudo amazon-linux-extras install java-openjdk11

For java 8 you can try:

sudo yum install java-1.8.0-openjdk

Finally, if you want to switch between java versions run:

sudo alternatives --config java

Answer from rahimli on Stack Overflow
🌐
AWS re:Post
repost.aws › questions › QUyIfeuRXISUCrJPlXYKWGlw › java-11-openjdk-devel-for-amazon-linux-2
java-11-openjdk-devel for Amazon Linux 2 | AWS re:Post
January 31, 2019 - The plan at this point is to make the package available in the Amazon Linux extras repositories. ... Hello, The java-11-openjdk package is now available in the Amazon Linux 2 extras repositories.
🌐
AWS
docs.aws.amazon.com › corretto › corretto 11 user guide › amazon corretto 11 guide for linux › amazon corretto 11 installation instructions for amazon linux 2 and amazon linux 2023
Amazon Corretto 11 Installation Instructions for Amazon Linux 2 and Amazon Linux 2023 - Amazon Corretto 11
There is also a 'devel' package which contains the JDK development tools, as well as a 'jmods' package that contains the Amazon Corretto 11 JMods used to create custom runtime images. Option 1: Install the headless Amazon Corretto 11: ... While it is recommended to use /usr/lib/jvm/java-11-amazon-corretto.<cpu_arch> location, installation may also add alternative links making installation location accessible via /etc/alternatives/jre, /etc/alternatives/jre_11 and /etc/alternatives/jre_11_openjdk ...
Discussions

centos7 - Is there a way to install OpenJDK Java in Amazon Linux 2023? - Stack Overflow
In the process of trying out a switch to Amazon Linux 2023 from Centos7 and I am trying to understand my options for Java. I am currenly running Java 11 openjdk in Centos7. Ideally I'd like to matc... More on stackoverflow.com
🌐 stackoverflow.com
How to install openjdk-11.0.16 version in amazon linux 2
I have to install a specific version of openjdk i.e, openjdk-11.0.16 in amazon linux 2. I don't want to install coretto11. we can install using amazon-linux-extras install java-openjdk11, but this... More on repost.aws
🌐 repost.aws
1
0
November 23, 2022
Installing java11 with yum (on AWS EC2 Linux instance)
I use sdkman to install jdk 11. More on reddit.com
🌐 r/learnjava
2
5
July 24, 2019
Installation instructions for Corretto 25 failing on EC2
Which repos do you have enabled? More on reddit.com
🌐 r/aws
14
1
October 16, 2025
Top answer
1 of 7
68

Another option might be running the following commands:

In order to install java 11:

sudo amazon-linux-extras install java-openjdk11

For java 8 you can try:

sudo yum install java-1.8.0-openjdk

Finally, if you want to switch between java versions run:

sudo alternatives --config java

2 of 7
18

Sharing my simple working approach

Downloading the JDK

curl -LO https://corretto.aws/downloads/latest/amazon-corretto-11-x64-linux-jdk.tar.gz

note: check the ec2 instance's platform ie., x64, aarch64, x86, aarch32 etc.,because the wrong platform jdk installation will leads to /bin/java: /bin/java: cannot execute binary file

Extracting the JDK to /usr/java/

sudo tar -xvzf amazon-corretto-11-x64-linux-jdk.tar.gz -C /usr/java/

Run the below single line command to change the soft link for java files in (/usr/bin) directory

cd /usr/java/amazon-corretto-*-linux-x64/bin
for i in java javac jfr; do path=$(find `pwd`/$i -type f); echo $path; sudo alternatives --install /usr/bin/i $path 20000 ; sudo update-alternatives --config $i ; done

after the above command execution, there will be a command prompt that will ask you to choose the selection number which represents the file residing path and we should choose the number which refers to path /usr/java/amazon-corretto-*-linux-x64/bin/

The amazon-corretto jdk version may vary based on the timeline that you download. Currently the java version is 11.0.12.7.1

That's it execute java -version, you can see the java version as

openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment Corretto-11.0.12.7.1 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.12.7.1 (build 11.0.12+7-LTS, mixed mode)
🌐
CloudKatha
cloudkatha.com › home › how to install openjdk 11 on amazon linux 2
How to Install OpenJDK 11 on Amazon Linux 2 - CloudKatha
August 29, 2023 - The package that contains JDK 11 is java-11-openjdk-devel and to my surprise, it is available in the core repository itself. Install JDK on Amazon Linux2 using the below command-
🌐
AWS
docs.aws.amazon.com › corretto › corretto 11 user guide › amazon corretto 11 guide for linux › amazon corretto 11 installation instructions for debian-based, rpm-based and alpine linux distributions
Amazon Corretto 11 Installation Instructions for Debian-Based, RPM-Based and Alpine Linux Distributions - Amazon Corretto 11
Download the Linux .rpm file from the Downloads page. Install the downloaded .rpm file using yum localinstall. For example install x86_64 rpm using the following command: sudo yum localinstall java-11-amazon-corretto-devel-11.0.31.11-1.x86_64.rpm · In the terminal, run the following command to verify the installation. ... openjdk ...
🌐
TecAdmin
tecadmin.net › install-java-on-amazon-linux
How to Install Java (JDK/JRE) on Amazon Linux – TecAdmin
April 26, 2025 - To install Java 11, execute the following command: ... 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 "11.0.22" 2024-01-16 LTS OpenJDK Runtime Environment Corretto-11.0.22.7.1 (build 11.0.22+7-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.22.7.1 (build 11.0.22+7-LTS, mixed mode)
Find elsewhere
🌐
LinuxShout
linux.how2shout.com › home › how to install java 8/11 on amazon linux 2023
How to install Java 8/11 on Amazon Linux 2023 - LinuxShout
June 24, 2023 - Here we go through the commands available to install Java 11 or 8 on Amazon Linux 2023 for production or business applications in your cloud infrastructure. Java is available through the Amazon 2023 repositories as Corretto. ... Amazon Corretto ...
🌐
DEV Community
dev.to › aws-builders › install-java-11-on-amazon-linux-2-2k1i
Install Java 11 on Amazon Linux 2 - DEV Community
January 11, 2023 - Posted on Jan 11, 2023 · #aws #amazonlinux #installjava11 · Command: sudo yum update · sudo amazon-linux-extras install java-openjdk11 · Type "Y" for install packages · Wait until all packages finished install · Command: java -version ...
🌐
AWS
docs.aws.amazon.com › corretto › corretto 21 user guide › amazon corretto 21 guide for linux › amazon corretto 21 installation instructions for amazon linux 2023
Amazon Corretto 21 Installation Instructions for Amazon Linux 2023 - Amazon Corretto 21
There is also a 'devel' package which contains the JDK development tools, as well as a 'jmods' package that contains the Amazon Corretto 21 JMods used to create custom runtime images. Option 1: Install the headless Amazon Corretto 21: ... While it is recommended to use /usr/lib/jvm/java-21-amazon-corretto.<cpu_arch> location, installation may also add alternative links making installation location accessible via /etc/alternatives/jre, /etc/alternatives/jre_21 and /etc/alternatives/jre_21_openjdk ...
🌐
iHusyn
ihusyn.wordpress.com › 2019 › 11 › 01 › how-to-install-java-11-on-amazon-linux
How to install Java 11 on Amazon Linux | iHusyn
February 21, 2024 - sudo curl -o java11.rpm https://d3pxv6yz143wms.cloudfront.net/11.0.5.10.1/java-11-amazon-corretto-devel-11.0.5.10-1.x86_64.rpm · From the same directory execute the following command to install java 11 ... openjdk version "11.0.5" 2019-10-15 LTS OpenJDK Runtime Environment Corretto-11.0.5.10.1 (build 11.0.5+10-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.5.10.1 (build 11.0.5+10-LTS, mixed mode)
🌐
Amazon
alas.aws.amazon.com › AL2 › ALASJAVA-OPENJDK11-2024-006.html
ALASJAVA-OPENJDK11-2024-006
Visit this page to learn more about Amazon Linux 2 (AL2) Extras and this FAQ section for the difference between AL2 Core and AL2 Extras advisories. Issue Correction: Run yum update java-11-openjdk to update your system. ... aarch64: java-11-openjdk-11.0.21.0.9-1.amzn2.0.1.aarch64 java-11-openjdk-debug-11.0.21.0.9-1.amzn2.0.1.aarch64 java-11-openjdk-headless-11.0.21.0.9-1.amzn2.0.1.aarch64 java-11-openjdk-headless-debug-11.0.21.0.9-1.amzn2.0.1.aarch64 java-11-openjdk-devel...
🌐
Amazon
alas.aws.amazon.com › AL2 › ALASJAVA-OPENJDK11-2021-001.html
ALAS2JAVA-OPENJDK11-2021-001
December 17, 2021 - Visit this page to learn more about Amazon Linux 2 (AL2) Extras and this FAQ section for the difference between AL2 Core and AL2 Extras advisories. Issue Correction: Run yum update java-11-openjdk to update your system. ... aarch64: java-11-openjdk-11.0.13.0.8-1.amzn2.0.3.aarch64 java-11-openjdk-debug-11.0.13.0.8-1.amzn2.0.3.aarch64 java-11-openjdk-headless-11.0.13.0.8-1.amzn2.0.3.aarch64 java-11-openjdk-headless-debug-11.0.13.0.8-1.amzn2.0.3.aarch64 java-11-openjdk-devel...
🌐
Amazon Web Services
aws.amazon.com › products › developer tools › amazon corretto
Production-ready distribution of OpenJDK – Amazon Corretto
2 weeks ago - Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with no-cost long-term support. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard.
🌐
Awswithatiq
awswithatiq.com › how-to-install-java-on-amazon-linux-2023
How to Install Java on Amazon Linux 2023 – AWS with Atiq
This command will download and install the Java Development Kit (JDK) version 1.8 on your Amazon Linux instance. Feel free to adjust the version number based on your specific requirements.
🌐
Amazon
alas.aws.amazon.com › AL2 › ALASJAVA-OPENJDK11-2024-008.html
ALASJAVA-OPENJDK11-2024-008
May 20, 2024 - Visit this page to learn more about Amazon Linux 2 (AL2) Extras and this FAQ section for the difference between AL2 Core and AL2 Extras advisories. Issue Correction: Run yum update java-11-openjdk to update your system. ... aarch64: java-11-openjdk-11.0.23.0.9-2.amzn2.0.1.aarch64 java-11-openjdk-debug-11.0.23.0.9-2.amzn2.0.1.aarch64 java-11-openjdk-headless-11.0.23.0.9-2.amzn2.0.1.aarch64 java-11-openjdk-headless-debug-11.0.23.0.9-2.amzn2.0.1.aarch64 java-11-openjdk-devel...
🌐
AWS re:Post
repost.aws › questions › QUY8xB-CpKRWWmk-eCzpn0TQ › how-to-install-openjdk-11-0-16-version-in-amazon-linux-2
How to install openjdk-11.0.16 version in amazon linux 2 | AWS re:Post
November 23, 2022 - wget https://builds.openlogic.com/downloadJDK/openlogic-openjdk-jre/11.0.16+8/openlogic-openjdk-jre-11.0.16+8-linux-x64.tar.gz mv openlogic-openjdk-jre-11.0.16+8-linux-x64 /usr/jdk-11.0.16 # add this to your /etc/profile export JAVA_HOME=/usr/jdk-11.0.16 export PATH=$PATH:$JAVA_HOME/bin # then,you just source this env source /etc/profile # check the java version [root@ip-172-31-23-10 ~]# java -version openjdk version "11.0.16" 2022-07-19 OpenJDK Runtime Environment OpenLogic-OpenJDK (build 11.0.16+8-adhoc.root.jdk11u) OpenJDK 64-Bit Server VM OpenLogic-OpenJDK (build 11.0.16+8-adhoc.root.jdk11
🌐
CloudKatha
cloudkatha.com › home › how to install java 8/11/17 on amazon linux 2023 instance
How to Install Java 8/11/17 on Amazon Linux 2023 Instance - CloudKatha
September 5, 2023 - If you are wondering about amazon-corretto in the package name- Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the OpenJDK or Open Java Development Kit. Corretto comes with long-term support that will include performance enhancements and security fixes. It is backed by Amazon and provides long-term support. ... This means you are ideally installing OpenJDK 8/11/17 using the above package.
🌐
Tenable
tenable.com › plugins › nessus › 160993
Amazon Linux 2 : java-11-openjdk (ALASJAVA-OPENJDK11-2021-001)<!-- --> | Tenable®
May 12, 2022 - The version of java-11-openjdk installed on the remote host is prior to 11.0.13.0.8-1. It is, therefore, affected by multiple vulnerabilities as referenced in the ALAS2JAVA-OPENJDK11-2021-001 advisory. No versions of an Amazon Linux Java Virtual Machine (JVM) are affected by CVE-2021-44228 or CVE-2021-45046. However, if customers load a log4j version that is affected by CVE-2021-44228 or CVE-2021-45046 into an Amazon Linux JVM, it will introduce the issues identified in CVE-2021-44228 and CVE-2021-45046 into the JVM. This update modifies Amazon Linux packages that provide a JVM to also install the AWS-developed hotpatch to mitigate CVE-2021-44228 or CVE-2021-45046 by default.
🌐
ComputingForGeeks
computingforgeeks.com › home › install java 21 (openjdk 21) on amazon linux 2023
Install Java 21 (OpenJDK 21) on Amazon Linux 2023 [Guide]
March 16, 2026 - There are two methods of installing Java 21 on Amazon Linux 2023: ... The GNU General Public License version 2 applies to OpenJDK, which is a free and open-source implementation of the Java Platform, Standard Edition.