Sunday, August 3, 2014

Install JDK 8 on Raspberry Pi and set JAVA_HOME and PATH

The new Raspbian come with java 1.8.0 with path set, but no JAVA_HOME.
If you need set JAVA_HOME for the preload java in new Raspbian, refer to my updated post "Set JAVA_HOME for Raspbian pre-loaded java 1.8.0".

This post show how to download JDK 8 on a host computer running Ubuntu Linux (not on Raspberry Pi), then copy to Raspberry Pi, ssh to Pi to setup JDK 8 and set JAVA_HOME and PATH in .bashrc.

To download JDK 8 on a host computer, visit:, follow the steps to download Java SE Development Kit (JDK) for ARM.

In the following steps,
  • jdk-8u6-linux-arm-vfp-hflt.tar.gz is the downloaded file
  • is the IP address of Raspberry Pi
  • pi is the user in Raspberry Pi
Open Terminal, switch to the download folder.

Run the command to copy the downloaded file to Raspberry Pi:
$ scp jdk-8u6-linux-arm-vfp-hflt.tar.gz pi@

Log-in Raspberry Pi via ssh:
$ ssh -X -l pi
(-X is option)

Un-pack the file to /opt
$ sudo tar -zxvf jdk-8u6-linux-arm-vfp-hflt.tar.gz -C /opt

Edit .bashrc, to set JAVA_HOME and PATH:
$ nano .bashrc

Add the two line
export JAVA_HOME=/opt/jdk1.8.0_06
export PATH=$JAVA_HOME/bin:$PATH

where /opt/jdk1.8.0_06 is the unpacked folder of the new JDK.

Finally reboot Raspberry Pi.

- Try demo of Java SE 8 for ARM on Raspberry Pi

No comments: