How to Install Java SE 19 on Ubuntu 22.04

In this tutorial, we are going to explain in step-by-step detail how to install Java SE 19 on Ubuntu 22.04 OS.

Java SE platform or Java Standard Edition is a computing platform for the development and deployment of portable Java code on server environments.

It is portable for deployment on desktops and can be installed on different operating systems, such as Windows, MacOS, but in this blog post, we will focus on installing it on Linux server environments.

OpenJDK is a free and open-source implementation of the Java SE Platform Edition. The other type of Java is the Oracle JDK which is more enterprise-oriented.

Installing Java SE on Ubuntu 22.04 is a straightforward process that may take up to 10 minutes. Let’s get started!

Prerequisites

  • A server with Ubuntu 22.04 as OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the System

Before we start with the installation of Java, it is recommended to update the system packages to their latest versions available.

sudo apt-get update -y && sudo apt-get upgrade -y

Step 2. Install Java SE 19 from Default Repository

There are two ways of installing Java SE 19 on Ubuntu 22.04. The first way is to install it from the Ubuntu 22.04 default repository with the following command:

sudo apt install openjdk-19-jdk openjdk-19-jre

After installation, you can check the installed version with the following command:

java --version

The output should look like this:

root@host:~# java --version
openjdk 19.0.2 2023-01-17
OpenJDK Runtime Environment (build 19.0.2+7-Ubuntu-0ubuntu322.04)
OpenJDK 64-Bit Server VM (build 19.0.2+7-Ubuntu-0ubuntu322.04, mixed mode, sharing)

Step 3. Install Java SE 19 from the Debian package Manually

The second way is to install Java with the Debian package downloaded from the official Java SE development kit website. To download the Java SE 19 development kit faster, execute the following command:

cd /opt

wget https://download.oracle.com/java/19/archive/jdk-19.0.2_linux-x64_bin.deb

Before we continue with the installation, we need to install some prerequisites:

sudo apt install libc6-i386 libc6-x32 libxi6 libxtst6 -y

Once the prerequisites are installed and Java is downloaded, execute the following command:

dpkg -i jdk-19.0.2_linux-x64_bin.deb

The installation process will start:

root@host:/opt# dpkg -i jdk-19.0.2_linux-x64_bin.deb
Selecting previously unselected package jdk-19.
(Reading database ... 129849 files and directories currently installed.)
Preparing to unpack jdk-19.0.2_linux-x64_bin.deb ...
Unpacking jdk-19 (19.0.2-ga) ...

Once the installation process is finished, we need to set the Java variables using the following commands:

export JAVA_HOME=/usr/lib/jvm/jdk-19/
export PATH=$PATH:$JAVA_HOME/bin

Now, open the /etc/environment file with your favorite editor and paste the following line at the bottom:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
JAVA_HOME="/usr/lib/jvm/jdk-19"

Next, activate the Java environment variable with the following command:

source /etc/environment

The last thing is to update the alternatives with the correct Java directory

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-19/bin/java 1

After this, you can check the installed version with the following command:

java --version

The output should look like this:

root@host:/usr/lib/jvm/jdk-19# java --version
java 19.0.2 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)

That’s it. You successfully installed and managed to configure Java SE 19 on Ubuntu 22.04 in two different ways.

Of course, if this setup is difficult for you, please contact our technical support. We are available 24/7 and will help you with any aspect of Java SE 19 installation and configurations. All you need to do is to sign up for one of our managed VPS hosting plans and submit a support ticket.

If you liked this post on how to install Java SE 19 on Ubuntu 22.04, please share it with your friends on social networks or simply leave a reply below. Thanks.

2 thoughts on “How to Install Java SE 19 on Ubuntu 22.04”

  1. This happens when you do sudo apt install openjdk-19-jdk openjdk-19-jre:

    E: Unable to locate package openjdk-19-jdk
    E: Unable to locate package openjdk-19-jre

    Reply
    • Before start with the installation of java, it is recommended to update the system packages to their latest versions available. Also, you can follow the steps to install Java SE 19 from the Debian package manually.

      Reply

Leave a Comment