My Raspberry Pi 3 came with Java version 1.8.0_65 installed. I could not update it to a later version using apt-get - I assume there's no Debian repo for it. I do not know how to update it, and installing a newer version does not replace the existing one.

What's the bet way to install/update Java on Raspbian, and keep it updated going forward?

  • There's a rather fiddly process involving calling update-alternatives for each component of the JRE/JDK. Oracle doesn't provide an auto-update service, as you need to manually log in to their site to download updates.Unless this is mission critical, I'd stick with the default Raspbian oracle-java8-jdk
    – scruss
    Commented Sep 18, 2016 at 15:53
  • @traveling-tech-guy If any of the answers below, answered your question, please mark them so. If you solved it in a different way, please post an answer to your own question and mark that.
    – not2qubit
    Commented Mar 22, 2017 at 13:20
  • @not2qubit none did, I had to uninstall and re-install. See my comment to second answer. Commented Mar 22, 2017 at 17:34

4 Answers 4


To have all the time the most recent Oracle java installed, you can do check current Java

pi@raspberrypi:~ $ java -version java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

remove OpenJDK

sudo apt-get purge openjdk*

add digital key

sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886

add packet source

sudo vim /etc/apt/sources.list

add following lines

deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

install Java 8

sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

remove old Java

sudo apt-get purge openjdk*
sudo apt-get purge java7*
sudo apt-get autoremove

check success

java -version

pi@raspberrypi:~ $ java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) Client VM (build 25.131-b11, mixed mode)

  • 1
    Great answer. I only had to notice that the command apt-key was pasted with the long dash, which at some point had to accidentally replace double dashes -- so the command did not work, and resulted in weird error: gpg: conflicting commands. I have edited the answer to correct it.
    – SWilk
    Commented Nov 11, 2017 at 20:39
  • 2
    This didn't work with Rasbian Stretch. The instructions at gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f worked for me. Commented May 15, 2018 at 3:22
  • sudo apt-get purge java7* removed oracle-java8-jdk... Commented Dec 8, 2019 at 6:19

The following advice by hannes ach and SWilk was successful, but I got the following error:

pi@raspberrypi:~ $ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C2518248EEA14886 
Executing: /tmp/apt-key-gpghome.hVyJ3FPvDb/gpg.1.sh --recv-keys --keyserver keyserver.ubuntu.com C2518248EEA14886 
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory 
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.hVyJ3FPvDb/S.dirmngr' failed: No such file or directory 
gpg: keyserver receive failed: No dirmngr

In order to resolve that, I ran:

sudo apt-get install dirmngr --install-recommends


sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C2518248EEA14886

Then, everything worked as expected.

Original info from here https://blog.sleeplessbeastie.eu/2017/11/02/how-to-fix-missing-dirmngr/


If you want new features now it's possible to get version 9 and 10 like this:

wget https://github.com/bell-sw/Liberica/releases/download/10/bellsoft-jre10-linux-arm32-vfp-hflt.debsudo
apt install ./bellsoft-jre10-linux-arm32-vfp-hflt.deb

Liberica for Raspberry Pi: https://www.bell-sw.com/java-for-raspberry-pi.html


Have you tried this guide yet? http://elinux.org/RPi_Java#Installing_Java_on_Raspberry_Pi


sudo apt-get update
sudo apt-get install openjdk-7-jdk

Oracle Java 8

wget http://www.java.net/download/JavaFXarm/jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
tar zxf jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
rm jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz
sudo mv ./jdk1.8.0/ /opt/
sudo chown root:root -R /opt/jdk1.8.0/
sudo ln -s /opt/jdk1.8.0/ /opt/jdk8

Edit sudo nano -w /etc/profile and add


java -version

to see if java is working

  • 1
    Thanks for the detailed question, but I already have Java 8 installed. My question has to do with updating to newer versions. Commented Apr 18, 2016 at 14:32
  • Does not work, the apt-get installed Java is taking precedence on the path since it is in /usr/bin/java Commented Aug 25, 2016 at 8:52
  • 3
    These are very old instructions, and are no longer valid
    – scruss
    Commented Sep 18, 2016 at 15:40
  • +1 to switch to openjdk, be it for 7 or 8 if possible. It's much easier to keep current than manually download new releases from the oracle web-page than with a simple apt. The default version can easily be switched with sudo update-alternatives --config java; sudo update-alternatives --config java and only needs to be done once.
    – MadMike
    Commented Feb 21, 2017 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.