AWS - How to install java11 on an EC2 Linux machine?
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
Use one of the OpenJDK distributions:
https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html
or
https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot