I am guessing you are using amazon linux ami

sudo yum install java 


then press tab twice it will show you list of available options like below

Then complete the installation with chosen version example

sudo yum install java-11-amazon-corretto-headless.x86_64
Answer from JustTry on Stack Overflow
Top answer
1 of 2
1

I am guessing you are using amazon linux ami

sudo yum install java 


then press tab twice it will show you list of available options like below

Then complete the installation with chosen version example

sudo yum install java-11-amazon-corretto-headless.x86_64
2 of 2
-1

The error message Unable to find a match: java-1.8.0-openjdk means that the yum package manager cannot find the java-1.8.0-openjdk package in the repositories. This can happen if the package is not available in the repositories, or if the repositories are not configured correctly.

To fix this error, you can try the following:

  1. Make sure that the repositories are configured correctly. You can do this by running the following command:
sudo yum repolist

This will list all of the repositories that are configured on your EC2 instance. Make sure that the repository that contains the java-1.8.0-openjdk package is listed.

  1. If the repository is listed, try updating the repositories:
sudo yum update

This will update the package manager's knowledge of the repositories.

  1. If the package is still not found, you can try installing it manually. You can download the java-1.8.0-openjdk RPM package from the Oracle website. Once you have downloaded the RPM package, you can install it using the following command:
sudo yum localinstall java-1.8.0-openjdk-*.rpm

Once the java-1.8.0-openjdk package is installed, you should be able to run the java -version command without any errors.

Here are some additional tips for installing Java on EC2:

  • You can also use the Amazon Corretto distribution of OpenJDK, which is available in the Amazon Linux repositories. To install Corretto, run the following command:
sudo yum install java-11-amazon-corretto-11.0.5+10-1.amzn2.x86_64
Discussions

To install Java 8 on Amazon EC2 Linux using Ansible Playbook
Hi AWS, I have written an Ansible Playbook to install Java8 on EC2 Linux instance but while doing so I am facing this error fatal: [11.111.111.111]: FAILED! More on repost.aws
🌐 repost.aws
2
0
August 7, 2023
java - AWS - How to install java11 on an EC2 Linux machine? - Stack Overflow
This command "sudo amazon-linux-extras install java-openjdk11" just states that amazon-linux-extras doesnt exist. ... amazon-linux-extras is only available on Amazon Linux 2 (and does work). If you're using a different Linux distribution, then you have to use one of the other suggested options below. ... Sign up to request clarification or add additional context in comments. ... This works only if you open up outbound https in your Security Group assigned to your EC2 instance... More on stackoverflow.com
🌐 stackoverflow.com
To automate fetching Java version installed in EC2 instances across multiple AWS accounts
If the goal is CVE identification, Amazon Inspector does the detection automatically using the same SSM inventory command. More on reddit.com
🌐 r/aws
1
1
December 14, 2023
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
🌐
Medium
mnzel.medium.com › how-to-install-java-on-your-amazon-ec2-instance-8598aa67a628
How to install Java on your Amazon EC2 instance in 2025? | by Manzeel Uprety | Medium
February 21, 2025 - scp -i "mypemfile.pem" ~/Downloads/jdk-11.0.25_linux-x64_bin.tar.gz ubuntu@ec2-x-xxx-xx-0.ap-south-1.compute.amazonaws.com:/usr/lib/jvm · 2️⃣ Once the upload is complete, reconnect to your EC2 instance and navigate to the jvm directory: ... update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-11.0.25/bin/java" 0 update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-11.0.25/bin/javac" 0
🌐
Medium
codewithmuh.medium.com › install-java-on-the-redhat-linux-ec2-instance-4eb613011044
Install Java on the RedHat Linux EC2 instance | by CodeWithMuh | Medium
November 27, 2022 - Install Java on the RedHat Linux EC2 instance Launch Red-hat Linux EC2 instance SSH into your instance with Terminal to connect with the instance Run this command to become a Root User $ sudo su - …
🌐
DZone
dzone.com › coding › tools › installing java 8 on aws ec2 amazon linux instance
Installing Java 8 on AWS EC2 Amazon Linux Instance
January 30, 2018 - I am not going to waste your time and will instead jump directly towards the commands that you have to execute to install JDK 8 on your new instance. Before we start, please ensure you have the administrative privileges. OK. So, you have to execute the following commands as mentioned below. $ cd /opt $ sudo wget --no-cookies --no-check-certificate --header "Cookie: ://www.oracle.com/; -securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz $ sudo tar xzf jdk-8u151-linux-x64.tar.gz $ cd jdk1.8.0_151/ $ sudo alternatives --install /usr/bin/java java /opt/jdk1.8.0_151/bin/java 2 $ sudo alternatives --config java There are 2 programs which provide 'java'.
🌐
AWS
docs.aws.amazon.com › neptune › user guide › securing your amazon neptune database › connecting to your amazon neptune database using aws identity and access management authentication › prerequisites for connecting amazon neptune databases using iam authentication
Prerequisites for connecting Amazon Neptune databases using IAM authentication - Amazon Neptune
The following are instructions ... and Java 8 on an Amazon EC2 instance. These are required for the Amazon Neptune Signature Version 4 authentication samples. Connect to your Amazon EC2 instance with an SSH client. Install Apache Maven on your EC2 instance. If using Amazon Linux 2023 (preferred), ...
🌐
LinkedIn
linkedin.com › pulse › how-install-java-your-amazon-ec2-instance-manzeel-uprety-1e
How to install Java on your Amazon EC2 instance?
August 24, 2021 - ... Depending upon you internet speed, it will take up to a few minutes. Now you can connect back to your instance and navigate to your jvm folder. Unzip the tar file using the following command. Hit Enter.
Find elsewhere
🌐
LearnAWS
learnaws.io › blog › java-ec2-deployment
How to deploy Java on Amazon EC2 (Spring Boot edition)
June 21, 2024 - First launch an Amazon Linux EC2 instance, then connect to it using SSH. Install Java 17, copy the JAR file to EC2 with rsync. Run the server using systemd.
🌐
Eternal Blog
eternalsoftsolutions.com › home › guide on how to install java in aws ec2
How to install Java in AWS EC2: Ultimate Guide
February 11, 2023 - Configure Security Group (Please make sure you have SSH port 22 open in the security group) & click on Next ... If you are fairly new to AWS environment, you should know “how to launch an EC2 instance in AWS”. ... $ chmod 400 new_keypair.pem #if you have a new key pair $ ssh -i new_keypair.pem ubuntu@public_ip_address · By update and upgrading the server you will get the latest packages and versions to install in the server. ... You may need the Java Development Kit (JDK) in addition to the JRE in order to compile and run some specific Java-based software.
🌐
Medium
medium.com › @sambhaji2134 › install-latest-oracle-jdk-on-linux-ec2-instance-78eda5d62cc6
Install Latest Oracle JDK On Linux EC2 Instance | by Sambhaji Karad | Medium
October 1, 2019 - As can be seen in the above, is java is installed or not on the EC2 instance by default. If not installed then follow the next step: wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm
🌐
THE NUCLEAR GEEKS
thenucleargeeks.com › 2019 › 12 › 12 › install-java-on-aws-ec2-instance
Install Java on EC2 – THE NUCLEAR GEEKS
January 23, 2020 - Prerequisite of this tutorial is you should have AWS Account free tier will work. Step 1: Open AWS EC2 instance and launch new instance RedHat Enterprise Linux and add Security Group with Port ...
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-java-jdk11-on-aws-ec2
How to Install Java JDK11 on AWS EC2? - GeeksforGeeks
July 23, 2025 - Step 3: Connect to your EC2 Instance by clicking on Connect Button. Step 4: A prompt will pop up after connecting. Step 5: At first check, if Java JDK is already installed or not.
🌐
Medium
medium.com › @samb333 › installing-java-on-aws-ubuntu-ec2-instance-4499c1aa6f4c
Installing Java on AWS Ubuntu ec2 instance | by fisheye | Medium
January 4, 2024 - Installing Java on AWS Ubuntu ec2 instance we will install jdk or j2se from oracle Hardware Lets find what hardware we have .Following hardware on linux are common. There is biglist we will just list …
🌐
AWS re:Post
repost.aws › questions › QUz_J0wOaQSbacKNlQIp0d7A › to-install-java-8-on-amazon-ec2-linux-using-ansible-playbook
To install Java 8 on Amazon EC2 Linux using Ansible Playbook | AWS re:Post
August 7, 2023 - pre_tasks: - name: Enable amzn2-core repository command: amazon-linux-extras enable java-openjdk11 when: ansible_distribution == "Amazon" and ansible_distribution_major_version == "2" - name: Update yum cache if needed. yum: update_cache: true · Consider Using the package Module: Instead of using the yum module, you can use the package module, which is more abstract and works with different package managers. This might help if there's something specific to the yum module causing the issue: - name: Install Java.
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 $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)
🌐
Quora
quora.com › How-can-I-install-Java-on-an-EC2-instance
How to install Java on an EC2 instance - Quora
Answer (1 of 3): Ec2 instance nothing but your virtual machine. Connect to EC2 - Firstly,you can connect ec2 with ssh or there is another capability provided by aws to connect Ec2 that is “ec2 connect” from where you can directly connect to ec2 without ssh.
🌐
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
🌐
AWS
aws.amazon.com › blogs › compute › running-java-applications-on-amazon-ec2-a1-instances-with-amazon-corretto
Running Java applications on Amazon EC2 A1 instances with Amazon Corretto | Amazon Web Services
October 25, 2019 - This post is contributed by Jeff Underhill | EC2 Principal Business Development Manager and Arthur Petitpierre | Arm Specialist Solutions Architect Amazon EC2 A1 instances deliver up to 45% cost savings for scale-out applications and are powered by AWS Graviton Processors that feature 64-bit ...
🌐
Medium
medium.com › @migarathiranagama › how-to-install-java-in-an-ec2-instance-cc700dab972
How To Install Java In An EC2 Instance | by migara thiranagama | Medium
December 13, 2021 - How To Install Java In An EC2 Instance. there are some linux commands that you need to know if you are willing to install java into your running ec2 instance.
🌐
Medium
medium.com › @usuladams › how-to-install-apache-tomcat-and-java-on-ec2-linux-2-131911de0c13
How to Install Apache Tomcat and Java on EC2 Linux 2 | Medium
August 24, 2022 - ssh -i private-key-name ec2-user@ec2-public-IP-address/public-DNS-name · 1. Update the installed packages and package cache on your instance. sudo yum update -y · 2. Install Java JDK on Amazon Linux · Tomcat’s RUNNING.txt which you can ...