TECHOREVIEW

Raspberry Pi

How to Install Oracle Java JDK 16 on Raspberry Pi?

Spread the love

The Java Development Kit (JDK) is a tool for creating and testing Java programs. Java programmers from all over the world utilize it. Oracle JDK 16 was recently released. A Raspberry Pi version of Oracle JDK 16 is also available. I’ll show you how to install Oracle JDK 16 on a Raspberry 4 in this article. So, let’s get this started.

Raspberry Pi

What are the requirements for installation?

Oracle JDK 16 is only compatible with 64-bit ARM CPUs. For Oracle JDK 16 to run, your Raspberry Pi must have a 64-bit operating system installed. On the Raspberry Pi 4, we have tutorials for installing some of the most popular 64-bit operating systems. You can look them up if you need any help with that.

  • Install Ubuntu Server 20.04 LTS on a Raspberry Pi in Headless Mode and SSH onto it
  • Ubuntu Desktop 20.04 LTS on Raspberry Pi 4: Install Ubuntu Desktop 20.04 LTS
  • Ubuntu MATE 20.04 LTS on Raspberry Pi 4: Install Ubuntu MATE 20.04 LTS
  • Installing Kali Linux on a Raspberry Pi 4
  • Installing Debian on a Raspberry Pi 4

Download Oracle JDK 16 on your computer

Oracle JDK 16 is available for download from Oracle’s official website.

  1. First, open your favorite web browser and go to the official JDK 16 download page, then click on the Linux ARM 64 Compressed Archive download link (JDK-16.0.1 Linux-aarch64 bin.tar.gz) as shown in the screenshot below.
  2. As seen in the screenshot below, check the box next to I reviewed and accept the Oracle Technology Network License Agreement for Oracle Java SE and then click Download JDK-16.0.1 Linux-aarch64 bin.tar.gz.
  3. Choose a location for the Oracle JDK 16 archive file to be saved, then click Save.
  4. The archive file for Oracle JDK 16 is being downloaded. It can take some time to finish.
  5. As shown in the screenshot below, the Oracle JDK 16 archive file should be downloaded at this point.

Open JDK 16 Archive File Copying to Raspberry Pi

Raspberry Pi

You must transfer the Oracle JDK 16 archive file JDK-16.0.1 Linux-aarch64 bin.tar.gz to your Raspberry Pi once it has been downloaded. You can use SFTP or a USB flash drive to accomplish so. This section will show you how to transfer the Oracle JDK 16 archive file JDK-16.0.1 Linux-aarch64 bin.tar.gz to your Raspberry Pi using the SFTP protocol.

  1. To connect to your Pi through the SFTP protocol, open a Terminal session in the directory where you downloaded the Oracle JDK 16 archive file and type the following command.
  2. Press once you’ve entered your login password.
  3. You should be logged in at this point.
  4. Run the following SFTP command to transfer the Oracle JDK archive file JDK-16.0.1 Linux-aarch64 bin.tar.gz to your Raspberry Pi:
  • sftp> put JDK-16.0.1_linux-aarch64_bin.tar.gz
  1. The JDK-16.0.1 Linux-aarch64 bin.tar.gz archive file for Oracle JDK 16 should be copied to your Raspberry Pi.
  2. Now, use the following SFTP command to end the SFTP session:
  • sftp> exit

Installing Oracle JDK 16 on raspberry pi

Raspberry Pi

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

To begin, connect to your Raspberry Pi using SSH as follows:

Press Enter> after entering your login password.

You should be using SSH to connect to your Raspberry Pi.

The Oracle JDK 16 archive file JDK-16.0.1 Linux-aarch64 bin.tar.gz should be located in your Raspberry Pi’s HOME directory.

  • $ ls –LH

In the /opt directory, extract the Oracle JDK 16 archive file JDK-16.0.1 Linux-aarch64 bin.tar.gz as follows.

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

You should see a new directory JDK-16.0.1/ in the /opt directory once the Oracle JDK 16 archive file has been extracted, as seen in the screenshot below. Keep the directory name in mind since you’ll need it soon.

  • $ ls -LH /opt

Now you must add Oracle JDK 16 to your Raspberry PATH so that you may use the Oracle JDK 16 commands normally. Using the nano text editor, create a new file called jdk16.sh in the /etc/profile.d/ directory as follows:

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

In the jdk16.sh file, type the following lines.

  • export JAVA_HOME=”/opt/jdk-16.0.1″
  • export PATH=”$PATH:${JAVA_HOME}/bin”

When you’re finished, save the jdk16.sh file by pressing Ctrl + X, then Y and Enter.

When you’re done, use Ctrl + X, then Y, Enter to save the jdk16.sh file.

  • $ sudo reboot

The /opt/JDK-16.0.1/bin directory should be added to the PATH shell variable after your Raspberry boots.

  • $ echo $PATH

You should now be able to use the JDK commands java, javac, and others. You should be running Java 16 if you print the version of the java and javac commands.

  • $ java -version
  • $ javac –version

On the Raspberry Pi, test Oracle JDK 16

Create a new Java source file called HelloWorld.java to see if you can construct a simple Java program with Oracle JDK 16.

  • $ nano HelloWorld.java

In the HelloWorld.java source file, type the following lines of code.

When you’re finished, save the HelloWorld.java source file by pressing Ctrl + X, then Y, Enter.

Run the following command to compile the HelloWorld.java source file:

  • $ javac HelloWorld.java

A new file HelloWorld.class should be created. It indicates that the source file HelloWorld.java was successfully compiled.

  • $ ls –LH

After compiling the HelloWorld.java source file, execute the HelloWorld program as follows:

  • $ java HelloWorld

The HelloWorld program printed the text Hello World! on the screen. Oracle JDK 16 allows you to compile and run Java programs. It’s functioning perfectly.

Conclusion

I’ve shown you how to get Oracle JDK 16 for Raspberry Pi in this article. I also demonstrated how to set up Oracle JDK 16 on your Raspberry. I’ve also taught you how to develop and run a basic Java program on your Pi using Oracle JDK 16.

Read more from Techoreview.com

Power BI Tutorial: (4.2) How to Connect Power BI with SQL Server and MySQL?

Freelancing Tips and Top 10 Trending Services on Fiverr in 2022

How to Take a Screenshot on Macbook Pro Laptop ?

How to install Python 3.9 on Linux Ubuntu 20.04?

Leave a Comment

Your email address will not be published. Required fields are marked *