Skip to main content
Home Network

Updating Java on Raspberry Pi

By January 6, 2023No Comments

I couldn’t log in anymore on my Unifi Controller after updating the controller on my Raspberry Pi to version 5.10.12. All I got was a blank screen 🙁

After some digging around I noticed that Java needed to be updated. Rasbian is shipped with an outdated version of Java and for the Unifi Controller, we need at least version 1.8.0_201. So in this article, I am going to explain how you can update the Raspberry Pi Java version.

Updating Java

We are going to update Java on the PI. The problem is that the latest versions of Java aren’t available in the default repositories for Raspbian. So we need to add the correct repository manually to update Java.

Login to your PI with Putty or your preferred CLI (command-line interface) tool. First remove the OpenJDK:

1. <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">sudo apt-get purge openjdk*</font></font>

Add a digital key so we can authorize the repository

1. <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886</font></font>

Add the packet source

1. <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">sudo vim /etc/apt/sources.list</font></font>

Add the repository

1. <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">deb http://ppa.launchpad.net/webupd8team/java/ubuntu principal de confianza</font></font><font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
2. deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu principal de confianza</font></font>

Install the latest version of Java 8

1. <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">sudo apt-obtener actualización</font></font><font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
2. sudo apt-get install oracle-java8-installer</font></font><font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">
3. sudo apt-get install oracle-java8-set-default</font></font>

Remove the old Java version

1. <font style="vertical-align: inherit;"><font style="vertical-align: inherit;">sudo apt-get purge openjdk*</font></font><font></font>
2. sudo apt-get purge java7*<font></font>
3. sudo apt-get autoremove

Check if we have the latest version of Java:

1. java -version<font></font>
2. #java version "1.8.0_201"

Your Java Version on your Raspberry Pi should now be updated to the latest version. If you have the Unifi Controller running on it, all you need to do is reboot the Pi (sudo reboot).