Tuesday, 15 October 2024

How to Install JDK 21 on Linux and Amazon EC2 | JDK 21 Installation on Linux OS or Amazon EC2

🚀 Master Java & Cloud!

Subscribe to Ram N Java for the most simplified tech tutorials!

SUBSCRIBE TO OUR CHANNEL

How to Install JDK 21 on Linux or Amazon EC2

Setting up JDK 21 (a Long-Term Support version) on a Linux server or an Amazon EC2 instance is a core requirement for building modern, robust Java applications. This guide will walk you through the entire process step-by-step.

Step 1: System Update

Before any installation, it's vital to update your package repository to ensure system stability. Run the following commands:

sudo yum update -y
sudo yum upgrade -y

Step 2: Download JDK 21

Use the wget command to download the Linux x64 Compressed Archive directly from the Oracle website. This allows you to choose exactly where the JDK will reside.

wget [PASTE_JDK_21_DOWNLOAD_LINK_HERE]

Step 3: Extract the Archive

The standard practice is to install optional software in the /opt directory. Extract your downloaded .tar.gz file there:

sudo tar -xvf jdk-21_linux-x64_bin.tar.gz -C /opt

Step 4: Configure Path & Environment

To access Java from any terminal window, you need to set the JAVA_HOME and update your PATH variable in the /etc/profile file:

export JAVA_HOME=/opt/jdk-21.x.x
export PATH=$PATH:$JAVA_HOME/bin

Apply these changes by running: source /etc/profile

Step 5: Verify Your Setup

Confirm that everything is configured correctly by checking the version:

java -version
javac -version

📥 Download Free Resources!

I share the PowerPoint presentation and full source code for every tutorial! Head over to the YouTube video description to find the download links.

1 comment:

  1. This is the best blog design and article. Very nice job. Thank you very much...
    Best python full stack training in hyderabad

    ReplyDelete

Tutorials