Java 8 on Pi with Raspbian Lite

8Mar - by Simon - 0 - In SysAdmin

The Jessie Lite version of Raspbian for the Pi interestingly comes with perl and python, as well as GNU C and C++ compilers, but not with Java. This is useful for the Hadoop on Pi cluster project as we can install the full Oracle Java 8 JDK easily using the APT system, and there is no doubt as to the actual version we have installed (for Hadoop compatibility).

Java 8 on Pi installation is a snap. With sudo access (if using root then simply drop the sudo prefix on any command), execute the following:

sudo apt-get update

sudo apt-get install oracle-java8-jdk

Java 8 on Pi – job done. To test the installation then execute the following command from the prompt:

java -version

You should see results along the lines of:

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)

You may need to take care of setting environmental variables (especially the painful $JAVA_HOME) but these are stored against the individual user and (for the Hadoop installation at least) these will be set later. This is covered in the main articles.

Note: if you do need to set the JAVA_HOME variable then confirm the location of the Java executable by executing

which java

This will tell you the path of the Java software (the ‘bin’ or binary directory) and you can assign this path to the JAVA_HOME variable by executing

export JAVA_HOME=/the/path/to/bin

Note: Complications may arise if you have installed the full version of Raspbian on the Pi. For example, the full Jessie installation includes Java. If you then install Java 8 (the Oracle ‘official’ version) as above then you will need to tell the system to use the newly installed version of java. You can find more information in this article on the RPIBlog (jump to the commands under “Set default java and javac to the new installed jdk8” which show you how to use the update-alternatives command).

,

Leave a Reply

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