Java 17 is the latest long-term support release for the Java SE platform. As this is an LTS version, it will be supported until September 2024. Java 17 comes with multiple improvements and bug fixes. The workstation users should consider upgrading to this version. Also, production users can consider upgrading after checking all the application compatibility checks.

Advertisement

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:

sudo add-apt-repository ppa:linuxuprising/java 
sudo apt update 
sudo apt install oracle-java17-installer 

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.

sudo apt install oracle-java17-set-default 

After successfully installing Oracle Java 17 using the above steps, Let’s verify the installed version using the following command.

java -version >
Output:
java version "17.0.1" 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

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.

cat /etc/profile.d/jdk.sh 
Output:
export J2SDKDIR=/usr/lib/jvm/java-17-oracle export J2REDIR=/usr/lib/jvm/java-17-oracle export PATH=$PATH:/usr/lib/jvm/java-17-oracle/bin:/usr/lib/jvm/java-17-oracle/db/bin export JAVA_HOME=/usr/lib/jvm/java-17-oracle export DERBY_HOME=/usr/lib/jvm/java-17-oracle/db

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.

Share.

3 Comments

  1. Aadesh Senthilkumar on

    Very helpful article. I had trouble with my minecraft server because I didn’t know my default java version was set to 11 instead of 17.

Leave A Reply


Exit mobile version