19

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 Sep 18 '16 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 Mar 22 '17 at 13:20
  • @not2qubit none did, I had to uninstall and re-install. See my comment to second answer. – Traveling Tech Guy Mar 22 '17 at 17:34
10

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)

  • 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 Nov 11 '17 at 20:39
  • 2
    This didn't work with Rasbian Stretch. The instructions at gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f worked for me. – Kevin Doyon May 15 '18 at 3:22
3

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

then

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/

1

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

0

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

OpenJDK

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

PATH="$PATH":/opt/jdk8/bin
JAVA_HOME=/opt/jdk8

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. – Traveling Tech Guy Apr 18 '16 at 14:32
  • Does not work, the apt-get installed Java is taking precedence on the path since it is in /usr/bin/java – Wim Deblauwe Aug 25 '16 at 8:52
  • 2
    These are very old instructions, and are no longer valid – scruss Sep 18 '16 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 Feb 21 '17 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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