skip to Main Content

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


  1. 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:

    sudo yum update -y
    

    Install the amazon-linux-extras package manager if it is not available:

    sudo yum install -y amazon-linux-extras
    

    Enable and install OpenJDK 11:

    sudo amazon-linux-extras enable java-openjdk11
    sudo yum clean metadata
    sudo yum install -y java-11-openjdk
    

    Verify that Java has been installed successfully:

    java -version
    

    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.

    Login or Signup to reply.
  2. 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/bashrc

    source /etc/bashrc

    java –version

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search