If you have currently installed an updated Java version on a Raspberry Pi system and are searching for a way to update it to the latest version, you should follow this article for a brief guide.
How to Update Java on Raspberry Pi
To update Java on Raspberry Pi, ensure that your Raspberry Pi system does include the previous older version of Java and for that, you can use the following command:
Then perform the following steps to update Java on Raspberry Pi:
Step 1: Download Java’s Latest Version Source File
First, use the following command to download Java’s latest version source file on Raspberry Pi:
Note: The latest Java version only supports 64 Bit Raspberry Pi OS, so don’t forget to perform these steps on 64Bit OS.
Step 2: Extract the Java Source Content
Now, move the Java latest version source content to the /opt directory using the following command:
Step 3: Install Java Latest Version
Next run the following command to install Java as an alternative to the previously installed Java version and assign the priority number to it.
Similarly, use the following command to install Java Compiler as an alternative to previously installed Java compiler on Raspberry Pi and set its priority too.
Step 4: Configure Java Version
After installing the latest Java version on Raspberry Pi, it’s now time to configure the default Java for Raspberry Pi system and for that run the following command:
Note: You can skip this step if you don’t have any Java version installed on Raspberry Pi.
Select “1” to keep the updated Java version for Raspberry Pi system.
You can also select the default Java Compiler for Raspberry Pi system using the following command:
Select “1” as the default Java Compiler and once it’s done, you can confirm the Java version using the following command:
You can also confirm Java Compiler version using the following command:
Conclusion
You can update Java on the Raspberry Pi system by downloading the tar.gz file from the official source and then extracting the content to /opt directory. After that you have to perform the Java installation and then update the latest version with the older version using the “update-alternatives” command. Ensure selecting the latest Java and Java Compiler directory and run then run the version command to confirm updating the Java version on Raspberry Pi system.