How to install Amazon Corretto JDK on Ubuntu
Amazon Corretto or Corretto for short is a free and open-source distribution of the Open Java Development Kit. Developed by Amazon, Corretto is a cross-platform JDK distribution that is production ready. It comes with security and performance enhancements allowing developers to focus on writing code and not optimizing JDK performance.
In this tutorial, we will cover how to install the latest version of the Amazon Corretto JDK on Ubuntu and any Ubuntu Based distribution.
Install Corretto 18 with Apt
The first and most common method to install Amazon Corretto JDK is using the apt package manager. Follow the instructions as follows:
- Import the Corretto public key and add the repository to the repositories list as:
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
- Next, update the system repository:
sudo apt-get update
- Install Amazon corretto 18 by running:
sudo apt-get install java-common
Install Corretto 18 with DPKG
If you do not wish to make modifications to the system repository, you can install Corretto using the deb
package.
- Open the browser and navigate to the corretto downloads page:https://docs.aws.amazon.com/corretto/latest/corretto-18-ug/downloads-list.html
- Choose the package for your system and copy the download link.
- Open the terminal and run the command below to download the corretto installer package
wget https://corretto.aws/downloads/latest/amazon-corretto-18-x64-linux-jdk.deb
- Once downloaded, run the
dpkg
command to install
sudo dpkg -i amazon-corretto-18-x64-linux-jdk.deb
- Once the installation is complete, you can verify by running the command:
java -version
- You should see an output as shown below (for corretto 18)
openjdk 18.0.1 2022-04-19
OpenJDK Runtime Environment Corretto-18.0.1.10.1 (build 18.0.1+10-FR)
OpenJDK 64-Bit Server VM Corretto-18.0.1.10.1 (build 18.0.1+10-FR, mixed mode, sharing)
Uninstalling Amazon Corretto
If you wish to remove the corretto JDK, you can run the dpkg
command as shown:
sudo dpkg --remove java-18-amazon-corretto-jdk
Closing
And with that, you have successfully installed the latest version (as time of writing) of the Amazon Corretto JDK on your Debian based distribution.