yum - how to install amazon Corretto 17 on centos - Stack Overflow
java - How do I install JDK 17 on my AWS AMI Ec2 instance? - Stack Overflow
Make Package 'java-17-amazon-corretto-headless' available in https://yum.corretto.aws/
amazon ec2 - How do I install Java in an ec2 instance? - Stack Overflow
Videos
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
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:
- 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.
- If the repository is listed, try updating the repositories:
sudo yum update
This will update the package manager's knowledge of the repositories.
- If the package is still not found, you can try installing it manually. You can download the
java-1.8.0-openjdkRPM 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
To remove java 1.7 and install java 1.8:
sudo yum install java-1.8.0
sudo yum remove java-1.7.0-openjdk
Install Java Runtime 1.8
sudo yum install java-1.8.0
or if you need a java compiler and other developer tools:
sudo yum install java-1.8.0-openjdk-devel
Then use the alternatives command to make Java 1.8 the default.
sudo /usr/sbin/alternatives --config java
sudo /usr/sbin/alternatives --config javac
# etc
If you prefer you can remove Java 1.7 with
sudo yum remove java-1.7.0-openjdk
but remove it after you installed Java 1.8 or the aws-apitools will also be removed as they depend on Java on being installed.