How to Install Java on Amazon Linux 2023

You are currently viewing How to Install Java on Amazon Linux 2023

Java is a versatile and widely-used programming language that powers a vast number of applications and systems across various industries. If you’re an Amazon Linux user in 2023 and you’re looking to install Java on your system, you’ve come to the right place. In this step-by-step guide, we’ll walk you through the process of installing Java on Amazon Linux in 2023, ensuring you have all the necessary tools to run Java applications smoothly.


Before we dive into the installation process, make sure you have the following prerequisites:

  1. An Amazon Linux instance: Ensure you have access to an Amazon Linux server or EC2 instance with administrative privileges.
  2. Internet connectivity: A stable internet connection is required to download the necessary files and dependencies.

Now, let’s get started!

Step 1: Update the System:

To begin, it’s important to ensure that your Amazon Linux system is up to date. Open a terminal or SSH into your instance and execute the following command:

sudo dnf update -y

This command will update all the installed packages on your system, ensuring you have the latest software versions.

Step 2: Download and Install Java:

Amazon Linux uses OpenJDK, which is an open-source implementation of Java. Execute the following command to install OpenJDK on your system:

sudo dnf install java-17-amazon-corretto-devel

This command will download and install the Java Development Kit (JDK) version 1.8 on your Amazon Linux instance. Feel free to adjust the version number based on your specific requirements.

Step 3: Verify the Installation:

Once the installation process completes, you can verify that Java is successfully installed by running the following command:

java -version

If the installation was successful, you should see output similar to the following:

openjdk version "11.0.19" 2023-04-18 LTS
OpenJDK Runtime Environment Corretto- (build 11.0.19+7-LTS)
OpenJDK 64-Bit Server VM Corretto- (build 11.0.19+7-LTS, mixed mode)

Step 4: Test Java:

To confirm that Java is working correctly, you can compile and run a simple Java program. Create a file named using your preferred text editor:


Enter the following code into the file:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");

Save and exit the file. Then, compile and run the program with the following commands:

java HelloWorld

If everything is set up correctly, you should see the output:

Hello, World!


In this tutorial, we have walked through the step-by-step process of installing Java on Amazon Linux in 2023. By following these instructions, you now have a fully functional Java installation on your system. Whether you’re a developer or running Java-based applications

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply