Wednesday, 16 October 2024

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

🚀 Level Up Your Tech Skills!

Subscribe to Ram N Java for simplified AWS & Java tutorials!

SUBSCRIBE TO OUR CHANNEL

How to Install JDK 22 on Linux or Amazon EC2

Setting up JDK 22 on a Linux server or an Amazon EC2 instance is a fundamental step for Java developers. This guide provides a clear, step-by-step terminal process to get your environment ready for development.

Step 1: Update Your System

Always start by ensuring your package lists and installed packages are up to date. Run these commands in your terminal:

sudo yum update -y
sudo yum upgrade -y

Step 2: Download the JDK 22 Package

Download the Linux x64 Compressed Archive from the Oracle website using the wget command. This will pull the .tar.gz file directly to your server.

wget [DOWNLOAD_LINK_FOR_JDK_22]

Step 3: Extract to /opt Directory

Once downloaded, extract the archive into the /opt directory, which is a standard location for optional software:

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

Step 4: Configure Environment Variables

To use Java from any directory, update your /etc/profile file to include JAVA_HOME and update the PATH:

export JAVA_HOME=/opt/jdk-22.0.1
export PATH=$PATH:$JAVA_HOME/bin

Apply the changes immediately with: source /etc/profile

Step 5: Verify Your Installation

Finally, check that Java and the Java compiler are correctly installed and pointing to version 22:

java -version
javac -version

📥 Download Free Resources!

You can find the PowerPoint presentation and Java source code used in this tutorial in the YouTube video description above. Happy coding!

No comments:

Post a Comment

Tutorials