Java Development Kit (JDK) is used to develop and test Java applications. It is used by Java developers all around the world. Recently, Oracle JDK 16 was released. A version of Oracle JDK 16 is available for Raspberry Pi as well.

In this article, I will show you how to install Oracle JDK 16 on Raspberry Pi 4. So, let’s get started

Table of Contents

  1. Requirements
  2. Downloading Oracle JDK 16 on your Computer
  3. Copying Open JDK 16 Archive File to Raspberry Pi
  4. Installing Oracle JDK 16 on Raspberry Pi
  5. Testing Oracle JDK 16 on Raspberry Pi
  6. Conclusion

Requirements

Oracle JDK 16 is available for 64-bit ARM processors only. So, you must have a 64-bit operating system installed on your Raspberry Pi for Oracle JDK 16 to work.

We have tutorials on installing some of the most popular 64-bit operating systems on Raspberry Pi 4. You may check them out if you need any assistance on that.

  1. Ubuntu Server 20.04 LTS: Install Ubuntu Server on Raspberry Pi in Headless Mode and SSH Into It
  2. Ubuntu Desktop 20.04 LTS: Install Ubuntu Desktop 20.04 LTS on Raspberry Pi 4
  3. Ubuntu MATE 20.04 LTS: Install Ubuntu MATE 20.04 LTS on Raspberry Pi 4
  4. Kali Linux: Install Kali Linux on Raspberry Pi 4
  5. Debian: Install Debian on Raspberry Pi 4

NOTE: I will be using the 64-bit version of the Ubuntu Server 20.04 LTS operating system on my Raspberry Pi 4 for the demonstration. But any one of the 64-bit operating systems mentioned earlier should work just fine.

Downloading Oracle JDK 16 on your Computer

You can download Oracle JDK 16 from the official website of Oracle.

First, visit the official JDK 16 download page from your favorite web browser and click on the Linux ARM 64 Compressed Archive download link (jdk-16.0.1_linux-aarch64_bin.tar.gz) as marked in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-01.png" data-lazy- height="595" src="data:image/svg xml,” width=”974″>

Check the I reviewed and accept the Oracle Technology Network License Agreement for Oracle Java SE checkbox and click on Download jdk-16.0.1_linux-aarch64_bin.tar.gz as marked in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-02.png" data-lazy- height="595" src="data:image/svg xml,” width=”974″>

Select a directory where you want to save the Oracle JDK 16 archive file and click on Save.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-03.png" data-lazy- height="712" src="data:image/svg xml,” width=”974″>

Oracle JDK 16 archive file is being downloaded. It may take a while to complete.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-04.png" data-lazy- height="595" src="data:image/svg xml,” width=”974″>

At this point, Oracle JDK 16 archive file should be downloaded, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-05.png" data-lazy- height="595" src="data:image/svg xml,” width=”974″>

Copying Open JDK 16 Archive File to Raspberry Pi

Once the Oracle JDK 16 archive file jdk-16.0.1_linux-aarch64_bin.tar.gz is downloaded, you have to transfer it to your Raspberry Pi. You can do it via SFTP or using a USB thumb drive. This section will show you how to use the SFTP protocol to transfer the Oracle JDK 16 archive file jdk-16.0.1_linux-aarch64_bin.tar.gz to your Raspberry Pi.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-06.png" data-lazy- height="252" src="data:image/svg xml,” width=”974″>

Open a Terminal session on the directory where you have downloaded the Oracle JDK 16 archive file and type in the following command to connect to your Raspberry Pi via the SFTP protocol.

NOTE: Here, ubuntu is the login username, and 192.168.0.106 is the IP address of my Raspberry Pi 4. It will be different for you. So, make sure to replace them with yours.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-07.png" data-lazy- height="183" src="data:image/svg xml,” width=”441″>

Type in your login password and press .

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-08.png" data-lazy- height="216" src="data:image/svg xml,” width=”625″>

You should be logged in.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-09.png" data-lazy- height="293" src="data:image/svg xml,” width=”627″>

To transfer the Oracle JDK archive file jdk-16.0.1_linux-aarch64_bin.tar.gz on your Raspberry Pi, run the following SFTP command:

sftp> put jdk-16.0.1_linux-aarch64_bin.tar.gz

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-10.png" data-lazy- height="120" src="data:image/svg xml,” width=”727″>

The Oracle JDK 16 archive file jdk-16.0.1_linux-aarch64_bin.tar.gz should be transferred to your Raspberry Pi, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-11.png" data-lazy- height="127" src="data:image/svg xml,” width=”974″>

Now, close the SFTP session with the following SFTP command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-12.png" data-lazy- height="216" src="data:image/svg xml,” width=”633″>

Installing Oracle JDK 16 on Raspberry Pi

Once you’ve copied the Oracle JDK 16 archive file on your Raspberry Pi, you’re ready to install Oracle JDK 16 on your Raspberry Pi.

First, SSH into your Raspberry Pi as follows:

NOTE: Here, ubuntu is the login username, and 192.168.0.106 is the IP address of my Raspberry Pi 4. It will be different for you. So, make sure to replace them with yours.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-13.png" data-lazy- height="187" src="data:image/svg xml,” width=”435″>

Type in your login password and press .

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-14.png" data-lazy- height="222" src="data:image/svg xml,” width=”518″>

You should be logged in to your Raspberry Pi via SSH.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-15.png" data-lazy- height="752" src="data:image/svg xml,” width=”974″>

The Oracle JDK 16 archive file jdk-16.0.1_linux-aarch64_bin.tar.gz should be in the HOME directory of your Raspberry Pi, as you can see in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-16.png" data-lazy- height="181" src="data:image/svg xml,” width=”974″>

Extract the Oracle JDK 16 archive file jdk-16.0.1_linux-aarch64_bin.tar.gz in the /opt directory as follows:

$ sudo tar -xzf jdk-16.0.1_linux-aarch64_bin.tar.gz -C /opt

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-17.png" data-lazy- height="100" src="data:image/svg xml,” width=”974″>

Once the Oracle JDK 16 archive file is extracted in the /opt directory, you should see a new directory jdk-16.0.1/ in the /opt directory, as you marked in the screenshot below. Remember the directory name as you will need it very soon.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-18.png" data-lazy- height="202" src="data:image/svg xml,” width=”974″>

Now, you have to add Oracle JDK 16 to the PATH of your Raspberry Pi so that you can run access the Oracle JDK 16 commands as usual.

Create a new file jdk16.sh in the /etc/profile.d/ directory using the nano text editor as follows:

$ sudo nano /etc/profile.d/jdk16.sh

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-19.png" data-lazy- height="116" src="data:image/svg xml,” width=”800″>

Type in the following lines in the jdk16.sh file.

export JAVA_HOME=”https://linuxhint.com/opt/jdk-16.0.1″


export PATH=”$PATH:${JAVA_HOME}/bin”

Once you’re done, press X followed by Y and to save the jdk16.sh file.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-20.png" data-lazy- height="650" src="data:image/svg xml,” width=”974″>

Now, restart your Raspberry Pi for the changes to take effect.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-21.png" data-lazy- height="110" src="data:image/svg xml,” width=”454″>

Once your Raspberry Pi boots, you should see the /opt/jdk-16.0.1/bin directory added to the PATH shell variable as marked in the screenshot below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-22.png" data-lazy- height="472" src="data:image/svg xml,” width=”974″>

Now, you should be able to access the java, javac, and other JDK commands.

If you print the version of the java and javac commands, it should say that you’re running Java 16, as you can see in the screenshot below.

$ java -version


$ javac -version

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-23.png" data-lazy- height="312" src="data:image/svg xml,” width=”974″>

Testing Oracle JDK 16 on Raspberry Pi

To test whether you can compile a simple Java program using Oracle JDK 16, create a new Java source file HelloWorld.java as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-24.png" data-lazy- height="116" src="data:image/svg xml,” width=”595″>

Type in the following lines of codes in the HelloWorld.java source file.

public class HelloWorld {

public static void main(String[] args) {

System.out.println(“Hello World!”);

}

}

Once you’re done, press X followed by Y and to save the HelloWorld.java source file.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-25.png" data-lazy- height="472" src="data:image/svg xml,” width=”974″>

To compile the HelloWorld.java source file, run the following command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-26.png" data-lazy- height="110" src="data:image/svg xml,” width=”616″>

A new file HelloWorld.class should be generated, as you can see in the screenshot below. It means that the HelloWorld.java source file was successfully compiled.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-27.png" data-lazy- height="218" src="data:image/svg xml,” width=”974″>

Once the HelloWorld.java source file is compiled, you can run the HelloWorld program as follows:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-28.png" data-lazy- height="110" src="data:image/svg xml,” width=”543″>

As you can see, the HelloWorld program printed the text Hello World! On the screen. So, you can compile and run Java programs using Oracle JDK 16. It’s working just fine.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/Install-Oracle-Java-JDK-16-Raspberry-Pi-29.png" data-lazy- height="204" src="data:image/svg xml,” width=”647″>

Conclusion

In this article, I have shown you how to download Oracle JDK 16 for Raspberry Pi. I have also shown you how to install Oracle JDK 16 on your Raspberry Pi. I have shown you how to compile a simple Java program and run it with Oracle JDK 16 on your Raspberry Pi as well.

About the author

<img alt="" data-del="avatar" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/07/echo/photo2-150×150.png6100f08deebf3.jpg" height="112" src="data:image/svg xml,” width=”112″>

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.