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 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
While it is recommended to use ... /etc/alternatives/java_sdk_11_openjdk for JDK. The paths under /etc/alternatives/ may point to another JDK depending on the packages installed and system configuration. Download RPMs from the Downloads page for your CPU architecture. To install the JDK, you will need to download the RPMs for both the JDK and the JRE. Install using yum ...
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)
Discussions

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
Installing java11 with yum (on AWS EC2 Linux instance)
oh, I'm not the only one to have done exactly the same.First answer on google https://forums.aws.amazon.com/thread.jspa?threadID=297707 400 Bad Request Request Header Or Cookie Too Large More on reddit.com
🌐 r/javahelp
1
2
July 24, 2019
java-11-openjdk-devel for Amazon Linux 2
The java-11-openjdk repository should be available in ap-east-1 within the next few days. Thanks for using the Amazon Linux 2 AMI. ... I was able to install the java-openjdk11 from amazon-linux-extras. But how do I switch to OpenJDK11 on an Amazon Linux 2 instance? ... Amazon Linux 2 Yum Fails ... More on repost.aws
🌐 repost.aws
6
0
January 31, 2019
How to set java 11 path in amazon linux 2 docker image
This will set the JAVA_HOME environment ... on your Amazon Linux 2 Docker image. You can then use this environment variable to run Java 11 commands, such as java and javac, from anywhere in your container. In order for this to work, you will need to ensure that Java 11 is installed on your Docker image. You can do this by running yum install ... More on repost.aws
🌐 repost.aws
1
0
December 6, 2022
🌐
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 ...
🌐
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) There you go. No need to check Oracle website or search in yum repositories.
🌐
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
After the repository is added, you can install Corretto 11 by running this command: ... 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-ama...
🌐
TecAdmin
tecadmin.net › install-java-on-amazon-linux
How to Install Java (JDK/JRE) on Amazon Linux – TecAdmin
April 26, 2025 - Before proceeding, ensure you meet ... or command line. You have sudo privileges or access to the root user. Activate the yum repository on Amazon Linux 2....
🌐
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 - In this tutorial, I am here to ... 11 or Java 11 on Amazon Linux 2 EC2 instance in a step-by-step manner. Additionally, I’ll show you how to install JDK 11 apart from the JRE that OpenJDK 11 installs. You can also check my posts to install Nginx, Apache, PHP 8.2, Git, Ansible, PHP 8.1, Docker etc. on Amazon Linux 2. ... Amazon Linux 2: Amazon Linux 2 is a very popular Linux AMI provided by AWS itself and is also free tier eligible. You can use the Yum package manager ...
🌐
Reddit
reddit.com › r/learnjava › installing java11 with yum (on aws ec2 linux instance)
r/learnjava on Reddit: Installing java11 with yum (on AWS EC2 Linux instance)
July 24, 2019 -

I am trying to figure out how to install java11 on EC2

> sudo yum install java-11-openjdk-devel
Loaded plugins: priorities, update-motd, upgrade-helper
1147 packages excluded due to repository priority protections
No package java-11-openjdk-devel available.
Error: Nothing to do

I tried to clean yum

> sudo yum clean all
> sudo yum clean metadata

Still doesn't work. Tried to download it manually:

> sudo wget http://vault.centos.org/7.6.1810/updates/Source/SPackages/java-11-openjdk-11.0.3.7-0.el7_6.src.rpm
> sudo rpm -ihv java-11-openjdk-11.0.3.7-0.el7_6.src.rpm

Still

No package java-11-openjdk-devel available.

What do I need to do?

Find elsewhere
🌐
Reddit
reddit.com › r/javahelp › installing java11 with yum (on aws ec2 linux instance)
r/javahelp on Reddit: Installing java11 with yum (on AWS EC2 Linux instance)
July 24, 2019 -

I am trying to figure out how to install java11 on EC2

> sudo yum install java-11-openjdk-devel
Loaded plugins: priorities, update-motd, upgrade-helper
1147 packages excluded due to repository priority protections
No package java-11-openjdk-devel available.
Error: Nothing to do

I tried to clean yum

> sudo yum clean all
> sudo yum clean metadata

Still doesn't work. Tried to download it manually:

> sudo wget http://vault.centos.org/7.6.1810/updates/Source/SPackages/java-11-openjdk-11.0.3.7-0.el7_6.src.rpm
> sudo rpm -ihv java-11-openjdk-11.0.3.7-0.el7_6.src.rpm

Still

No package java-11-openjdk-devel available.

What do I need to do?

🌐
javathinking
javathinking.com › blog › aws-how-to-install-java11-on-an-ec2-linux-machine
How to Install Java 11 on AWS EC2 Linux Machine: Fixing wget 404 Error & 'amazon-linux-extras Not Found' Issues — javathinking.com
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm -y sudo yum install java-11-openjdk-devel -y · ⚠️ Warning: Amazon Linux 1 is EOL.
🌐
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
sudo yum localinstall java-21-amazon-corretto*.rpm · In the terminal, run the following command to verify the installation. ... openjdk version "21.0.11" 2026-04-21 LTS OpenJDK Runtime Environment Corretto-21.0.11.10.1 (build 21.0.11+10-LTS) OpenJDK 64-Bit Server VM Corretto-21.0.11.10.1 (build ...
🌐
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 java-11-openjdk repository should be available in ap-east-1 within the next few days. Thanks for using the Amazon Linux 2 AMI. ... I was able to install the java-openjdk11 from amazon-linux-extras. But how do I switch to OpenJDK11 on an Amazon Linux 2 instance? ... Amazon Linux 2 Yum Fails with curl#60 SSL Certificate Error When Installing Nginx via amazon-linux-extras
🌐
DevelopnSolve
developnsolve.com › installing-java-on-amazon-linux
Installing Java on Amazon Linux - Develop and Solve
January 13, 2024 - Amazon Linux utilizes RPM Package Manager (YUM) to install and manage software packages. To get Java on Amazon Linux, you can use YUM to download and set up
🌐
Medium
medium.com › @kildongp › jdk-1-8-11-install-on-an-ec2-aws-linux-f98dc1555f0f
jdk 1.8/11 install on an EC2 aws linux - Kildongp - Medium
January 24, 2024 - jdk 1.8/11 install on an EC2 aws linux In order to install jdk and jps JDK 11 : sudo amazon-linux-extras install java-openjdk11-devel JDK 8 sudo yum install java-1.8.0-openjdk-devel -y switch between …
🌐
YouTube
youtube.com › shorts › DF6UyUWEU4I
How to Install Java JDK 11 on AWS EC2 Linux 2 Using Yum | No package java-11-openjdk-devel available - YouTube
In this video, I'll show you how to use yum to install the Java JDK (not just the JRE) on an AWS EC2 Linux 2 instance so that you can compile and run your Ja...
Published   May 11, 2021
🌐
SearchBlox
developer.searchblox.com › docs › installing-on-amazon-linux
Installing on Amazon Linux 2 - Architecture - SearchBlox
Amazon users can go with Amazon Linux 2023 vs Amazon Linux 2. Recommended EC2 instance type is g6.xlarge . Install OpenJDK 25 by running the following command: sudo yum install java-25-amazon-corretto-devel java -version
🌐
AWS
docs.aws.amazon.com › corretto › corretto 21 user guide › amazon corretto 21 guide for linux › amazon corretto 21 installation instructions for debian-based, rpm-based and alpine linux distributions
Amazon Corretto 21 Installation Instructions for Debian-Based, RPM-Based and Alpine Linux Distributions - Amazon Corretto 21
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-21-amazon-corretto-devel-21.0.11.10-1.x86_64.rpm
🌐
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). The development environment includes the runtime environment. Install Amazon Corretto 8 as JRE. ... Install Amazon Corretto 8 as JDK. ... While it is recommended to use /usr/lib/jvm/java...