I am using sudo amazon-linux-extras install java-openjdk11
this command,but it says
sudo: amazon-linux-extras: command not found
How I can install java in my ec2 ?
I am using sudo amazon-linux-extras install java-openjdk11
this command,but it says
sudo: amazon-linux-extras: command not found
How I can install java in my ec2 ?
3
Answers
It seems that the amazon-linux-extras package manager is not installed or not found in your system. Assuming you are using Amazon Linux 2, you can follow these steps to install OpenJDK 11 on your EC2 instance:
Update your system packages:
Install the amazon-linux-extras package manager if it is not available:
Enable and install OpenJDK 11:
Verify that Java has been installed successfully:
If everything went well, you should see the installed OpenJDK 11 version details.
Keep in mind that if you’re using a different version of Amazon Linux or another Linux distribution, the steps may vary.
you can download java 11 from https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
tar -xvf xxx.tar.gz -C /usr/local/bin
add
export PATH=${PATH}:/usr/local/bin/path-to-jdk-11/bin
to /etc/bashrcsource /etc/bashrc
java –version
Download Java 11 from java.net
wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
Extract it to /usr/local/bin:
sudo tar -xvf openjdk-11+28_linux-x64_bin.tar.gz -C /usr/local/bin
edit /etc/bashrc and add the following to the end of the file:
export PATH=${PATH}:/usr/local/bin/jdk-11/bin
export JAVA_HOME=/usr/local/bin/jdk-11
Run the source command to make sure the changes are reflected.
source /etc/bashrc
Check if Java has been installed
java --version
On Amazon Linux 2023, use:
sudo dnf install java-11-amazon-corretto -y