Amazon Corretto 8 Installation Instructions for Amazon Linux 2 - Amazon Corretto

Amazon Corretto 8 Installation Instructions for Amazon Linux 2

This topic describes how to install and uninstall Amazon Corretto 8 on a host or container running the Amazon Linux 2 operating system.

Option 1: Use the yum Package Manager on Amazon Linux

  1. Enable the yum repository in Amazon Linux 2.

    sudo amazon-linux-extras enable corretto8
  2. You can install Amazon Corretto 8 as either the runtime environment (JRE) or the full development environment (JDK). The development environment includes the runtime environment.

    Install Amazon Corretto 8 as JRE.

    sudo yum install java-1.8.0-amazon-corretto

    Install Amazon Corretto 8 as JDK.

    sudo yum install java-1.8.0-amazon-corretto-devel

    The installation location is /usr/lib/jvm/java-1.8.0-amazon-corretto.<cpu_arch>.

Option 2: Download and Install RPMs Manually

  1. Download RPMs from the Downloads page for your CPU architecture. To install the JDK, you will need to download the RPMs for both the JDK and the JRE.

  2. Install using yum localinstall.

    sudo yum localinstall java-1.8.0-amazon-corretto*.rpm

Verify Your Installation

In the terminal, run the following command to verify the installation.

java -version

Expected output for 8u232:

openjdk version "1.8.0_232" OpenJDK Runtime Environment Corretto- (build 1.8.0_232-b09) OpenJDK 64-Bit Server VM Corretto- (build 25.232-b09, mixed mode)

If you see a version string that doesn't mention Corretto, run the following command to change the default java or javac providers.

sudo alternatives --config java

If using the JDK you should also run:

sudo alternatives --config javac

Uninstall Amazon Corretto 8

You can uninstall Amazon Corretto 8 with the following commands.

Uninstall JRE:

sudo yum remove java-1.8.0-amazon-corretto

Uninstall JDK:

sudo yum remove java-1.8.0-amazon-corretto-devel