The Raspberry Pi is also a Debian-based Linux distribution in which we can install the JDK through its default repository. In this write-up, the installation methods of installing the JDK on Raspberry Pi have been discussed.
Method 1: How to install JDK on Raspberry Pi through apt repository
We can install the Java Development Kit’s package on the Raspberry Pi OS through the default repository of the Raspberry Pi, but before proceeding towards the installation, it is recommended to update and also upgrade all the packages of the repository by using the command:
Once all the packages of the repository are up to date, we will install the JDK package with the execution of the command:
To confirm the installation of the JDK package, we will check the version of the installed JDK using the command:
The JDK package of Java has successfully been installed on the Raspberry Pi, now, if you want to uninstall the java package from the Raspberry Pi, run the command:
How to install the latest 17.0.2 JDK on Raspberry Pi
Though the above method of installing the JDK package from the repository of Raspberry Pi is easy and fast, it doesn’t install the latest version of JDK package. Nowadays, the latest version of JDK is 17.0.2 which can be installed by using the sdkman package manager, for those who are not familiar with SDKMAN package manager, SDKMAN is a tool for managing parallel versions of different software development tool kit on operating systems like iOS, Android, and Linux. We can install, update, and uninstall different applications available in the library of the SDK manager.
How to install the SDKMAN on Raspberry Pi
We will first install the SDKMAN on the Raspberry Pi OS, for this purpose, we will use the curl command to download it from its official website using the command:
The “s” flag is used with the curl command to download the specified certificate file, then we will use the source command to read and execute of the SDKMAN file downloaded with the curl command:
With the successful execution of the above command, the SDK manager has been installed, to verify the installation, we will check the version of installed SDK:
How to install JDK using the SDKMAN on Raspberry Pi
After the successful installation of the SDKMAN, we will list down all the packages of JDK available in the library of SDK using the command:
A list will be displayed, scroll down to search the “Temurin” vendor and note down the “Identifier” against the 17.0.2 version:
Press “q” to quit the SDKMAN Java list and run the command to install the Java 17.0.2 version provided by the Temurin vendor using the SDKMAN package manager:
At the completion of the installation of JDK 17.0.2, it will set as the default, to cross-check the status of the Java, we will check its version using the command:
To uninstall the installed JDK package using the SDK manager, we will use the command:
Conclusion
Many applications are based on the Java language, and to manage these applications we need a JDK package. The JDK package can be installed using the default repository of the Raspberry Pi but the package available in the repository is not the latest version. In this write-up, we have discussed two different methods for the installation of the JDK on Raspberry Pi using its default repository as well as the SDKMAN.