How To Install Amazon Corretto 16 on Ubuntu 20.04
Posted on July 15, 2021 (Last modified on July 14, 2022) • 3 min read • 509 wordsLearn how to install Amazon Corretto 16 on Ubuntu 20.04. a no-cost, multiplatform, production-ready distribution of the OpenJDK.
In this tutorial we learn how to install Amazon Corretto 16 on Ubuntu 20.04. Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK).
It comes with long-term support that includes performance enhancements and security fixes. Corretto is certified as compatible with the Java SE standard and is used internally at Amazon for many production services.
Corretto also available for Java 8, Java 11, and Java 15. In this tutorial we learn how to setup Java 16 From Amazon Corretto 16.
First of all update apt package index using the command below.
sudo apt-get update
```bash
or we can also use apt command below.
```bash
sudo apt update
First, we will add Amazon Corretto public key to our system so apt can verify the packages that it download is not corrupt or broken.
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
```bash
### Add Amazon Corretto Repository Configuration {#h-add-amazon-corretto-repository-configuration}
Run the command below to add Amazon Corretto Repository configuration.
```bash
echo 'deb https://apt.corretto.aws stable main' | sudo tee /etc/apt/sources.list.d/corretto.list
Update apt metadata database.
sudo apt-get update
```bash
Install Amazon Corretto 16 using command below
```bash
sudo apt-get install java-16-amazon-corretto-jdk
In this section we will create a simple Java application, compile and run using Amazon Corretto 16 javac
and java
application.
First, create new file named HelloHowtoDojo.java
with contents below
class HelloHowtoDojo {
public static void main(String[] args) {
String java_class_path = System.getProperty("java.class.path");
String java_home = System.getProperty("java.home");
String java_vendor = System.getProperty("java.vendor");
String java_vendor_url = System.getProperty("java.vendor.url");
String java_version = System.getProperty("java.version");
String os_arch = System.getProperty("os.arch");
String os_name = System.getProperty("os.name");
String os_version = System.getProperty("os.version");
String user_dir = System.getProperty("user.dir");
String user_home = System.getProperty("user.home");
String user_name = System.getProperty("user.name");
System.out.println("Hello howtodojo!");
System.out.println("Java Class Path :" + java_class_path);
System.out.println("Java Home :" + java_home);
System.out.println("Java Vendor :" + java_vendor);
System.out.println("Java Vendor URL :" + java_vendor_url);
System.out.println("Java Version :" + java_version);
System.out.println("OS Architecture :" + os_arch);
System.out.println("OS Name :" + os_name);
System.out.println("OS Version :" + os_version);
System.out.println("User Dir :" + user_dir);
System.out.println("User Home :" + user_home);
System.out.println("User Name :" + user_name);
}
}
```bash
Second, compile the source code using command below.
```bash
javac HelloHowtoDojo.java
Third, let’s run the application that we just create and compile using Amazon Corretto 16.
$ java HelloHowtoDojo
Hello howtodojo!
Java Class Path :.
Java Home :/usr/lib/jvm/java-16-amazon-corretto
Java Vendor :Amazon.com Inc.
Java Vendor URL :https://aws.amazon.com/corretto/
Java Version :16.0.2
OS Architecture :amd64
OS Name :Linux
OS Version :4.16.0-135-generic
User Dir :/home/howtodojo
User Home :/home/howtodojo
User Name :howtodojo
```bash
## Related Tutorials {#h-related-tutorials}
<ul class="has-pale-cyan-blue-background-color has-background">
<li>
Install Amazon Corretto 8 on Ubuntu 20.04
</li>
<li>
<a href="https://www.howtodojo.com/install-amazon-corretto-11-ubuntu-18-04/">Install Amazon Corretto 11 on Ubuntu 20.04</a>
</li>
</ul>
## Summary {#h-summary}
In this tutorial we learn how to install Amazon Corretto 16 on Ubuntu 20.04. We also learn to create a simple “Hello howtodojo!” program, compile it using `javac` and run it using `java` that Amazon Corretto provides. Until next time.