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
docs.aws.amazon.com โ€บ corretto โ€บ corretto 17 user guide โ€บ amazon corretto 17 guide for linux โ€บ amazon corretto 17 installation instructions for amazon linux 2 and amazon linux 2023
Amazon Corretto 17 Installation Instructions for Amazon Linux 2 and Amazon Linux 2023 - Amazon Corretto 17
This topic describes how to install ... 17 on a host or container running the Amazon Linux 2 or Amazon Linux 2023 operating systems. Amazon Corretto 17 has a 'headless' variant available. This variant omits runtime dependencies that are typically associated with GUI applications such as X11 and ALSA and is worth considering for server-oriented workloads. The 'headful' variant adds support for X11 and ALSA. There is also a 'devel' package which contains the JDK development ...
๐ŸŒ
AWS
docs.aws.amazon.com โ€บ amazon linux โ€บ user guide โ€บ getting started with programming runtimes โ€บ java in al2
Java in AL2 - Amazon Linux 2
AL2 provides several versions of Amazon Corretto to support Java based workloads, as well as some OpenJDK versions. We recommend that you migrate to Amazon Corretto in preparation for migrating to AL2023.
Discussions

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
centos7 - Is there a way to install OpenJDK Java in Amazon Linux 2023? - Stack Overflow
The changes for Corretto are fairly ... Amazon Linux(s). It's natural to be cautious, but look at the changes yourself to see if there's anything scary: Change Log for Amazon Corretto 11. ... No such thing as "OpenJDK" that you can install, no such thing as "Java 11 openjdk". OpenJDK is an open-source project providing an implementation of the Java specification, but this project produces only source code, not binaries/installers. Several vendors provide JDK ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
java-11-openjdk-devel for Amazon Linux 2
Hello, The java-11-openjdk package is now available in the Amazon Linux 2 extras repositories. To install the java-11-openjdk packages on an Amazon Linux 2 instance run: ... Thanks for your request. -Heath ... Any word on when this will be available on beanstalk? As of now I only see JDK 7 and ... More on repost.aws
๐ŸŒ repost.aws
6
0
January 31, 2019
java - How do I install JDK 15 on my AWS Linux Ec2 instance? - Stack Overflow
I need to install jdk 15 on my Amazon ami linux instance of EC2. I can't seem to find it using the command sudo yum list available | grep java Any answers would be appreciated! More on stackoverflow.com
๐ŸŒ stackoverflow.com
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)
๐ŸŒ
AWS
docs.aws.amazon.com โ€บ corretto โ€บ corretto 8 user guide โ€บ amazon corretto 8 guide for linux โ€บ amazon corretto 8 installation instructions for amazon linux 2 and amazon linux 2023
Amazon Corretto 8 Installation Instructions for Amazon Linux 2 and Amazon Linux 2023 - Amazon Corretto 8
Enable the yum repository in Amazon Linux 2. This is not required on Amazon Linux 2022 and later. ... You can install Amazon Corretto 8 as either the runtime environment (JRE) or the full development environment (JDK).
๐ŸŒ
SearchBlox
developer.searchblox.com โ€บ docs โ€บ installing-on-amazon-linux
Installing on Amazon Linux 2
๐Ÿ“˜ NOTE:: Since Amazon Linux 2 end of support date (End of Life, or EOL) will be on 2026-06-30. (Was previously 06/2025). Amazon users can go with Amazon Linux 2023 vs Amazon Linux 2. Prerequisites Recommended EC2 instance type is g6.xlarge . Install OpenJDK 25 by running the following command: sudo...
๐ŸŒ
Reddit
reddit.com โ€บ r/aws โ€บ installation instructions for corretto 25 failing on ec2
r/aws on Reddit: Installation instructions for Corretto 25 failing on EC2
October 16, 2025 -

I've installed (and uninstalled) Corretto 21 easily on my EC2 instance, specifically using "sudo yum install java-21-amazon-corretto-devel" and "sudo yum remove java-21-amazon-corretto-devel" respectively.

However, when I follow the same instructions for Corretto 25 (see Amazon Corretto 25 Installation Instructions for Amazon Linux 2023 - Amazon Corretto 25) it doesn't work:

sudo yum install java-25-amazon-corretto-devel
Amazon Linux 2023 Kernel Livepatch repository 42 kB/s | 2.9 kB 00:00
Amazon Linux 2023 Kernel Livepatch repository 217 kB/s | 23 kB 00:00
Last metadata expiration check: 0:00:01 ago on Wed Oct 15 20:33:30 2025.
No match for argument: java-25-amazon-corretto-devel
Error: Unable to find a match: java-25-amazon-corretto-devel

And the failure is the same for other variants, like "sudo yum install java-25-amazon-corretto".

I've confirmed my EC2 is running Amazon Linux 2023.

Any idea what I'm missing..?

UPDATE: Corretto 25 was released late September, so I just had to update my OS: sudo dnf --releasever=latest update

๐ŸŒ
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 - #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 ยท Subscribe ยท For further ...
Find elsewhere
๐ŸŒ
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 - Hello, The java-11-openjdk package is now available in the Amazon Linux 2 extras repositories. To install the java-11-openjdk packages on an Amazon Linux 2 instance run: ... Thanks for your request.
๐ŸŒ
LinkedIn
linkedin.com โ€บ posts โ€บ prabhanu-gunaweera_how-to-install-java-on-amazon-linux-2-activity-7084172386123583488-CUng
Prabhanu Gunaweera on LinkedIn: How to install Java on Amazon Linux 2
July 10, 2023 - Check out my latest Medium article titled "How to Install Java on Amazon Linux 2". This is my 2nd article related to DevOps and my 11th article overall. Iโ€ฆ
๐ŸŒ
Linux Hint
linuxhint.com โ€บ install-jdk-on-amazon-linux-ec2
How to Install Java JDK on Amazon EC2
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
๐ŸŒ
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 - Letโ€™s check the installed version of java(runtime) and javac(compiler) using the below commands. ... As you run the above command, you will notice that the command sudo amazon-linux-extras install java-openjdk11 only installs JRE and not the JDK.
๐ŸŒ
Awswithatiq
awswithatiq.com โ€บ how-to-install-java-on-amazon-linux-2023
How to Install Java on Amazon Linux 2023 โ€“ AWS with Atiq
Execute the following command to install OpenJDK on your system: ... This command will download and install the Java Development Kit (JDK) version 1.8 on your Amazon Linux instance.
Top answer
1 of 1
5

OpenJDK Java 15 is not available for Linux AMI, and I don't imagine it will be.

According to https://aws.amazon.com/amazon-linux-ami/. AMI has entered the maintenance support phase of its end-of-life. That means:

"During this maintenance support period:

  • The Amazon Linux AMI will only receive critical and important security updates for a reduced set of packages.
  • It will no longer be guaranteed to support new EC2 platform capabilities, or new AWS features."

Doing new stuff (i.e. involving Java 15) on AMI is a bad idea.


The replacement for AMI is Amazon Linux 2. I can't find a browsable list of packages, so I can't tell you whether Java is available for it. (But I doubt it.)


When I search for AWS Java 15, I find a link to the Amazon Corretto: Corretto 15 User Guide. This has installation instructions for a number of OSes, and the relevant ones for AMI and Amazon Linux 2 are as follows:

To use Corretto RPM repositories with the yum package manager, import the Corretto public key and then add the repository to the system list. For most systems, you must run the following commands:

sudo rpm --import https://yum.corretto.aws/corretto.key  
sudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo

After the repository is added, you can install Corretto 15 by running this command:

sudo yum install -y java-15-amazon-corretto-devel

It is worth noting that many other vendors provide Java (many version) for generic Linux. One would expect that they could be installed on an AWS AMI instance. You would just need to follow the relevant instructions.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-install-java-jdk11-on-aws-ec2
How to Install Java JDK11 on AWS EC2? | GeeksforGeeks
April 20, 2023 - In this article, we are going to see a step-by-step guide on how you can install java on your Linux machine. Step-By-Step ... AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services.
๐ŸŒ
Linuxteaching
en.linuxteaching.com โ€บ article โ€บ how_to_install_java_118_on_amazon_linux
How to Install Java 11/8 on Amazon Linux | Linuxteaching
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. ... Step 2 โ€“ Check Active Java Version.
๐ŸŒ
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
๐ŸŒ
Amazon Web Services
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
This topic describes how to install ... 11 on a host or container running the Amazon Linux 2 or Amazon Linux 2023 operating systems. Amazon Corretto 11 has a 'headless' variant available. This variant omits runtime dependencies that are typically associated with GUI applications such as X11 and ALSA and is worth considering for server-oriented workloads. The 'headful' variant adds support for X11 and ALSA. There is also a 'devel' package which contains the JDK development ...