Tuesday, March 18, 2014

Install Oracle JDK 8 on Raspberry Pi

This post show how to download Oracle JDK 8 on a host PC running Ubuntu Linux, copy to, install and set default java and javac on Raspberry Pi.

Visit http://www.oracle.com/technetwork/java/javase/downloads/index.html, click the download button of Java Platform (JDK) 8. Click to Accept License Agreement, download jdk-8-linux-arm-vfp-hflt.tar.gz for Linux ARM v6/v7 Hard Float ABI.

Open terminal, enter the command to copy the download file to Raspberry Pi using scp.
$ scp jdk-8-linux-arm-vfp-hflt.tar.gz pi@<Raspberry Pi>:

Log-in Raspberry Pi, enter the command to extract jdk-8-linux-arm-vfp-hflt.tar.gz to /opt directory.
$ sudo tar zxvf jdk-8-linux-arm-vfp-hflt.tar.gz -C /opt

Set default java and javac to the new installed jdk8.
$ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0/bin/java 1

$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java

After all, verify with the commands with -verion option.
$ java -version
$ javac -version