This blog post will help you to install Oracle Java 17 on Ubuntu 22.04 LTS, 20.04 LTS, and 18.04 LTS using PPA. Follow the below steps to Install Java on the Ubuntu command line.

Installing Java 17 on Ubuntu

You need to enable an additional repository to your system to install Java 17 on Ubuntu VPS. After that install Oracle Java 17 on an Ubuntu system using apt-get. This repository contains a package named oracle-java17-installer, Which is not an actual Java package. Instead of that, this package contains a script to install Java on Ubuntu. Open a terminal and execute the below command to configure the PPA: During this process, you must have to accept the Oracle agreement to finish the installation. This will install Java 17 on your Ubuntu system.

Step 2 – Test Java Installation

The apt repository also provides the package oracle-java17-set-default to set Java 17 as your default Java version. This package will be installed along with Java installation. To make sure execute the below command. After successfully installing Oracle Java 17 using the above steps, Let’s verify the installed version using the following command.

Setup JAVA_HOME and JRE_HOME Variable

The installer script set the environment variable for you. You can find these variables in /etc/profile.d/jdk.sh script. All done, you have successfully installed Java 17 on a Linux system. You may also need to install a Tomcat server to run your Java web application.