Skip to content

Installing Java JDK 19 on Linux (Debian, Ubuntu)

Tutorials & Guides  ·   ·   ·  Updated on  ·  2 min Reading time

Want to install JDK 19 on your Debian or Ubuntu server? No problem!

In this blog post we'll show you step by step how to install the Java Development Kit (JDK) 19 on your Debian or Ubuntu system.

First you need to update your package lists. You can do that with the following command:

sudo apt update

Next, install the packages needed for the JDK 19 installation:

sudo apt install curl ca-certificates apt-transport-https gnupg -y

To install Oracle JDK 19, you first need to add the Oracle repository to your APT sources. Use the following command to add the Oracle public key:

curl -sL https://download.oracle.com/java/GA/jdk19/2/GPL/keytoolkit.asc | sudo apt-key add -

Now add the repository to your APT sources:

echo "deb http://download.oracle.com/java/GA/jdk19/2/GPL/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/jdk19.list

Update your package lists again:

sudo apt update

Now you can install JDK 19 with the following command:

sudo apt install oracle-java19-installer -y

You can check whether the installation was successful and which Java version is installed on your system with the following command:

java -version

Now it's time to set the environment variables. You can set the Java environment variables by running the following command:

sudo apt install oracle-java19-set-default

Congratulations! You've successfully installed JDK 19 on your Debian or Ubuntu server. Now you can start developing and running your Java applications.

Don't forget to check for updates regularly and install them, to make sure your system and applications stay current and secure. You can do this by running the following commands:

sudo apt update sudo apt upgrade -y

Frequently asked questions

Which command updates the package lists before installing JDK 19?
Run sudo apt update to refresh your package lists before starting the installation.
How do I add the Oracle JDK 19 repository to APT?
Add the Oracle public key with apt-key add, then add the repository line to /etc/apt/sources.list.d/jdk19.list with sudo tee, and run sudo apt update again.
How can I verify the JDK 19 installation and set it as default?
Run java -version to check the installed version, and sudo apt install oracle-java19-set-default to set the environment variables and make it the default.
Prepaid-Host.com is itself a provider of servers, web hosting and domains, and reports here on its own market. How we handle that is set out in our disclosure statement.