Categories: Ubuntu

How to Install Oracle Java 16 JDK On Ubuntu

JDK is a development kit intended to develop and run Java-based applications on various operating systems and servers. Java is the widely used object-oriented and open-source programming language with platform indecency.

To accomplish the purpose of developing and running Java programs, JDK is equipped with a variety of tools such as Java Runtime Environment, Java loader, Java archiver, compiler, and much more. As JDK is platform-independent and have key importance in Java programming, we have compiled this guide to get Oracle Java 16 JDK on Ubuntu.

How to install Oracle Java 16 JDK on Ubuntu

Let’s perform the installation using the Debian package by following the steps provided below.

Sponsored

Step 1: First, you must download Java-16-JDK by visiting the official website of Oracle. The link is provided below:

https://www.oracle.com/java/technologies/javase/jdk16-archive-downloads.html

After clicking the package name, the following license agreement page would appear.

The downloading requires an account of Oracle. You have to create and sign-in to it.

Note: Oracle has changed its terms and conditions and you would be asked to sign-in/sign-up to get the .deb package of the Java 16 JDK.

Step 2: After downloading it, you can install it by using the terminal. To do so, you are required to change the present working directory to where you have downloaded the file. In our case, it is in the “Downloads” directory:

$ cd Downloads

Now use the following command to start the installation of the downloaded file.

$ sudo apt install ./jdk-16.0.2_linux-x64_bin.deb

Apart from this, you can carry out the installation of the .deb package in the following manner as well.

$ sudo dpkg -i jdk-16.0.2_linux-x64_bin.deb

The above commands would install the Oracle JDK on your Ubuntu. However, the system cannot recognize it until you set the environment variables.

Sponsored

For instance, we have tried to get the version of java, but the command returned an error.

$ java –version

How to set environment variables for JDK on Ubuntu

After installation, it is required to add the necessary environment variables. To do so, open the “.bashrc” file as follows:

$ nano .bashrc

Add the following lines to the “.bashrc” file

$ export JAVA_HOME=/home/adnan/Downloads/jdk-16.0.2
$ export PATH=$JAVA_HOME/bin:$PATH

Press “CTRL+S” and “CTRL+X” to save and exit from the file.

Now, load the “.bashrc” file via the command provided here.

$ source .bashrc

Now, you will get the version of Java after providing the following command.

$ java –version

How to remove Oracle Java 16 JDK on Ubuntu

To remove the Java 16JDK from your Ubuntu system, the following command would remove the Oracle Java 16 JDK from Ubuntu.

$ sudo apt remove –autoremove jdk-16.0.2

Apart from this, you can make use of the dpkg command to remove the Oracle Java 16 JDK as well by using the command below.

$ sudo dpkg -r jdk-16.0.2

Conclusion

The Oracle Java 16 JDK can be installed on Ubuntu by using the Debian package of the JDK. This article provides an installation guide of Oracle Java 16 JDK on Ubuntu. JDK comprises various tools that assist the development and testing of Java-based applications. Here, you would have learned the installation of Oracle Java 16 JDK and setting up the environment variables for Oracle Java 16 JDK on Ubuntu. Additionally, we have also demonstrated various ways to remove Oracle Java 16 JDK from Ubuntu.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

3 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

4 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

5 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

5 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago