Java 17 is the latest long-term support release for the Java SE platform. As this is a LTS version, it will be supported for till September 2024. Java 17 comes with multiple improvements and bug fixes. The workstation users should consider to upgrade to this version. Also production users can consider to upgrade after checking all the application compatibility check.
Use this tutorial to Install Java 17 on Ubuntu 21.10, 20.04 LTS, 18.04 LTS, 16.04 LTS using PPA. Follow the below steps to Install Java on Ubuntu command line.
To install Java pervious LTS release on your system follow below links:
- Read this => Install Java 11 on Ubuntu 18.04 (Bionic)
- Read this => Install Java 11 on Ubuntu 16.04 (Xenial)
Step 1 – Install Java 17 on Ubuntu
You need to enable 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 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 Oracle agreement to finish installation. This will install Java 17 on your Ubuntu system.
Step 2 – Test Java Installation
The apt repository also provides 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.
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)
Step 3 – 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.
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 Tomcat server to run your Java web application. Use our another tutorial to Install Tomcat 7 or Install Tomcat 8 or Install Tomcat 9 on Ubuntu, Debian, and LinuxMint systems.