comments 6

Installing Java 8 on Raspberry Pi 3

Just recently, I’ve got a new Raspberry Pi 3 Model B and started experimenting with it. I’ve installed the latest Raspbian (Jessie Lite) on it because it’s the officially supported operating system and more importantly, it works out-of-the-box.

I was thinking of writing some applications for it so I decided to install Java since it’s the programming language I’m most familiar with.

There are basically two options available for Raspbian — you can either use OpenJDK or Oracle JDK. There are some limitations of OpenJDK for ARM systems which make it slower so I’ve decided to stick with Oracle JDK.

You can install oracle-java8-jdk package from the official Raspbian repositories but it only provides an old version of Java (8u65). If you want to use the latest version, you need to download the JDK directly from the Oracle’s website. Since Raspberry Pi is powered by ARM processor and Raspbian is a 32-bit OS, choose the Linux ARM 32 Hard Float ABI version.

When you download the right package, unpack it into /usr/java directory:

sudo mkdir /usr/java
cd /usr/java
sudo tar xf ~/jdk-8u111-linux-arm32-vfp-hflt.tar.gz

You can then create symbolic links in /usr/bin folder (so you’ll be able to use java command anywhere) by adding the following alternatives:

sudo update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_111/bin/java 1000

sudo update-alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_111/bin/javac 1000

At this point, you should be able to verify that your Java installation works by running the following command:

java -version

It should print something like this:

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode)

If you see similar output, you have successfully installed Java 8 on Raspberry Pi.

6 Comments

  1. Revtmyers

    Looked at several ways. Not only is your explanation simple, it works. At this time though instead of version 111 it is 131.

  2. Geert Vancompernolle

    Finally a web page that’s to the point. Spot on! Really what I was looking for. All other places do utterly and unnecessary complex things that pollute your (in my case) Raspberry Pi setup and in the end lead to nothing…

    In the mean time, version has changed to 1.8.0_211-b12.

    Your procedure works like a charm, thanks very much for sharing!

    Best,
    –Geert

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.