

# Amazon Corretto 21 Guide for Linux
<a name="linux-info"></a>

The topics in this section describe installation instructions for Amazon Corretto 21 on Linux platforms.

**Topics**
+ [

# Amazon Corretto 21 Installation Instructions for Debian-Based, RPM-Based and Alpine Linux Distributions
](generic-linux-install.md)
+ [

# Amazon Corretto 21 Installation Instructions for Amazon Linux 2023
](amazon-linux-install.md)

# Amazon Corretto 21 Installation Instructions for Debian-Based, RPM-Based and Alpine Linux Distributions
<a name="generic-linux-install"></a>

This topic describes how to install Amazon Corretto 21 on Debian-based, RPM-based and Alpine Linux distributions. 

If you need to install Amazon Corretto 21 on Amazon Linux, see [Installing on Amazon Linux](amazon-linux-install.md). 

## Install Amazon Corretto 21 on Debian-Based Linux
<a name="debian-install-instruct"></a>

This section describes how to install and uninstall Amazon Corretto 21 on a host or container running a Debian-based operating system.

### Using apt
<a name="amazon-corretto-yum-verify"></a>

To use the Corretto Apt repositories on Debian-based systems, such as Ubuntu, import the Corretto public key and then add the repository to the system list by using the following commands: 

**Example**  

```
wget -O - https://apt.corretto.aws/corretto.key | sudo gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg && \
echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" | sudo tee /etc/apt/sources.list.d/corretto.list
```

After the repo has been added, you can install Corretto 21 by running this command:

**Example**  

```
sudo apt-get update; sudo apt-get install -y java-21-amazon-corretto-jdk
```

For old version Ubuntu such as 14.04, you might encounter error like 

**Example**  

```
GPG error: https://apt.corretto.aws stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A122542AB04F24E3
```

 If so, add the public key via: 

**Example**  

```
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys A122542AB04F24E3
```

### Download and Install the Debian Package Manually
<a name="debian-deb-install-instruct"></a>

1.  Before you install the JDK, install the `java-common` package.   
**Example**  

   ```
   sudo apt-get update && sudo apt-get install java-common
   ```

1.  Download the Linux `.deb` file from the [Downloads](downloads-list.md) page. 

1.  Install the `.deb` file by using `sudo dpkg --install`. For example install x86\$164 deb using the following command:   
**Example**  

   ```
   sudo dpkg --install java-21-amazon-corretto-jdk_21.0.10.7-1_amd64.deb
   ```

### Verify Your Installation
<a name="debian-deb-verify"></a>

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

**Example**  

```
java -version
```
Expected output for 21.0.10:   

```
openjdk version "21.0.10" 2026-01-20 LTS
OpenJDK Runtime Environment Corretto-21.0.10.7.1 (build 21.0.10+7-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.10.7.1 (build 21.0.10+7-LTS, mixed mode, sharing)
```

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

**Example**  

```
sudo update-alternatives --config java
```
If you're using the JDK, you should also run the following.  

```
sudo update-alternatives --config javac
```

### Uninstall Amazon Corretto 21
<a name="debian-deb-uninstall"></a>

You can uninstall Amazon Corretto 21 by using the following command.

**Example**  

```
sudo dpkg --remove java-21-amazon-corretto-jdk
```

## Install Amazon Corretto 21 on RPM-Based Linux
<a name="rpm-linux-install-instruct"></a>

### Using yum
<a name="amazon-corretto-yum-install-instruct"></a>

To use Corretto RPM repositories with the yum package manager (such as Amazon Linux AMI), import the Corretto public key and then add the repository to the system list. For most systems, you must run the following commands:

**Example**  

```
sudo rpm --import https://yum.corretto.aws/corretto.key
sudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo
```

After the repository is added, you can install Corretto 21 by running this command:

**Example**  

```
sudo yum install -y java-21-amazon-corretto-devel
```

### Using zypper
<a name="w2aab9b7b9b5"></a>

To use Corretto RPM repositories with the zyppr package manager (such as openSUSE), import the Corretto public key and then add the repository to the system list by running the following commands: 

**Example**  

```
sudo zypper addrepo https://yum.corretto.aws/corretto.repo; sudo zypper refresh
```

After the repository is added, you can install Corretto 21 by running this command: 

**Example**  

```
sudo zypper install java-21-amazon-corretto-devel
```

### Download and install RPM package manually
<a name="rpm-install-instruct"></a>

1.  Download the Linux `.rpm` file from the [Downloads](downloads-list.md) page. 

1.  Install the downloaded `.rpm` file using `yum localinstall`. For example install x86\$164 rpm using the following command:   
**Example**  

   ```
   sudo yum localinstall java-21-amazon-corretto-devel-21.0.10.7-1.x86_64.rpm
   ```

### Verify Your Installation
<a name="rpm-verify"></a>

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

**Example**  

```
java -version
```
Expected output for 21.0.10:   

```
openjdk version "21.0.10" 2026-01-20 LTS
OpenJDK Runtime Environment Corretto-21.0.10.7.1 (build 21.0.10+7-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.10.7.1 (build 21.0.10+7-LTS, mixed mode, sharing)
```

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

**Example**  

```
sudo alternatives --config java
```
If you're using the JDK, you should also run the following.  

```
sudo alternatives --config javac
```

### Uninstall Amazon Corretto 21
<a name="rpm-uninstall"></a>

You can uninstall Amazon Corretto 21 by using the following command:

**Example**  

```
sudo yum remove java-21-amazon-corretto-devel
```

## Install Amazon Corretto 21 on Alpine Linux
<a name="alpine-linux-install-instruct"></a>

### Using Alpine Package Manager
<a name="amazon-corretto-alpine-install-instruct"></a>

To use Corretto Alpine repositories with the Alpine package manager import the Corretto public key and then add the repository to the system list. For most systems, you must run the following commands:

**Example**  

```
wget -O /etc/apk/keys/amazoncorretto.rsa.pub  https://apk.corretto.aws/amazoncorretto.rsa.pub
echo "https://apk.corretto.aws/" >> /etc/apk/repositories
apk update
```

After the repository is added, you can install Corretto 21 by running this command:

**Example**  

```
apk add amazon-corretto-21
```

### Uninstall Amazon Corretto 21
<a name="alpine-uninstall"></a>

You can uninstall Amazon Corretto 21 by using the following

Uninstall JDK:

**Example**  

```
apk del amazon-corretto-21
```

# Amazon Corretto 21 Installation Instructions for Amazon Linux 2023
<a name="amazon-linux-install"></a>

 This topic describes how to install and uninstall Amazon Corretto 21 on a host or container running the Amazon Linux 2023 operating systems. 

## Option 1: Install using the yum Package Manager on Amazon Linux
<a name="amazon-linux-install-instruct"></a>

 Amazon Corretto 21 has a 'headless' variant available. This variant omits runtime dependencies that are typically associated with GUI applications such as X11 and ALSA and is worth considering for server-oriented workloads. The 'headful' variant adds support for X11 and ALSA. There is also a 'devel' package which contains the JDK development tools, as well as a 'jmods' package that contains the Amazon Corretto 21 JMods used to create custom runtime images. 

Option 1: Install the headless Amazon Corretto 21:

**Example**  

```
sudo yum install java-21-amazon-corretto-headless
```

Option 2: Install the headful Amazon Corretto 21:

**Example**  

```
sudo yum install java-21-amazon-corretto
```

Option 3: Install the JDK for Amazon Corretto 21:

**Example**  

```
sudo yum install java-21-amazon-corretto-devel
```

Option 4: Install the JMods for Amazon Corretto 21:

**Example**  

```
sudo yum install java-21-amazon-corretto-jmods
```

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

 While it is recommended to use `/usr/lib/jvm/java-21-amazon-corretto.<cpu_arch>` location, installation may also add alternative links making installation location accessible via `/etc/alternatives/jre`, `/etc/alternatives/jre_21` and `/etc/alternatives/jre_21_openjdk` for JRE and `/etc/alternatives/java_sdk`, `/etc/alternatives/java_sdk_21` and `/etc/alternatives/java_sdk_21_openjdk` for JDK. The paths under `/etc/alternatives/` may point to another JDK depending on the packages installed and system configuration. 

## Option 2: Download and Install RPMs Manually
<a name="amazon-linux-rpm-install-instruct"></a>

1.  Download RPMs from the [Downloads](downloads-list.md) page for your CPU architecture. To install the JDK, you will need to download the RPMs for both the JDK and the JRE. 

1.  Install using `yum localinstall`.   
**Example**  

   ```
   sudo yum localinstall java-21-amazon-corretto*.rpm
   ```

## Verify Your Installation
<a name="amazon-linux-verify"></a>

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

**Example**  

```
java -version
```
Expected output for 21.0.10:   

```
openjdk version "21.0.10" 2026-01-20 LTS
OpenJDK Runtime Environment Corretto-21.0.10.7.1 (build 21.0.10+7-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.10.7.1 (build 21.0.10+7-LTS, mixed mode, sharing)
```

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

**Example**  

```
sudo alternatives --config java
```
If using the JDK you should also run:  

```
sudo alternatives --config javac
```

## Uninstall Amazon Corretto 21
<a name="amazon-linux-uninstall"></a>

You can uninstall Amazon Corretto 21 with the following commands.

Uninstall headless:

**Example**  

```
sudo yum remove java-21-amazon-corretto-headless
```

Uninstall headful:

**Example**  

```
sudo yum remove java-21-amazon-corretto
```

Uninstall devel:

**Example**  

```
sudo yum remove java-21-amazon-corretto-devel
```

Uninstall jmods:

**Example**  

```
sudo yum remove java-21-amazon-corretto-jmods
```