|« Nepal Day 1 - Heathrow, Mumbai, Kathmandu||Installing Oracle Java 7 on Raspbian wheezy »|
Installing Oracle Java 8 on Raspbian wheezyJuly 16th, 2013
I had great trouble installing Oracle Java on my Raspberry Pi due to the liblji.so problem. The main Raspberry documentation tells you that you must use the soft-floating point (SFP) version of “wheezy” in order to run Oracle Java as it doesn’t have a version compiled for using the hardware floating-point (i.e. normal Raspbian).
It was only after I had re-installed everything using the software-floating point
versions (see Installing Oracle Java 7 on Raspbian wheezy) that I stumbled across a forum post that said there was a beta of Oracle Java 8 bundled with the JavaFX libraries that was compiled using the normal hardware floating point.
So here are the instructions for that.
- Using the instructions Installing and setting up a Raspberry Pi, install Raspbian “wheezy”,
2013-05-25-wheezy-raspbian(at the time of writing).
- Navigate to the JDK 8 Early Access Releases, accept the agreement and download the Linux ARM HardFP.
- Copy the file to the Raspberry Pi (from the command line).
scp jdk-8-ea-b97-linux-arm-vfp-hflt-03_jul_2013.tar.gz firstname.lastname@example.org:/home/pi
- Open a session to the Raspberry Pi.
- Do my
sudo bashtrick again to open a root shell. This will stop us having to write sudo in front of everything. It also has the handy benefit of separating the history of your sessions with extraneous commands that you wouldn’t normally use.
- Also there now! Create somewhere for Oracle Java to live and uncompress the downloaded zip file.
mkdir -p /opt/java
tar -xvzf /home/pi/jdk-8-ea-b97-linux-arm-vfp-hflt-03_jul_2013.tar.gz
- Now we’ll tell the system about the Oracle Java 8 installation. (Note double minus on the –install and ‐set).
update-alternatives –install “/usr/bin/java” “java” “/opt/java/jdk1.8.0/bin/java” 1
- We must also tell the system that we want it to use this version of Oracle Java 8 by default.
update-alternatives –set java /opt/java/jdk1.8.0/bin/java
- Now test:
root@drswifty:/home/pi# java -version
java version “1.8.0″
Java™ SE Runtime Environment (build 1.8.0)
Java HotSpot™ Client VM (build 25.0-b97, mixed mode)
- The Java that has been installed here is the Java Runtime Environment (JRE). So when you type
javayou’re getting the JRE version and not the Java Development Kit version and as a result you are not getting
javaceither. This is ok because all the applications on the platform will run under it. As developers we need the JDK version so we’ll have to rejig our
PATHenvironment variable so it picks up the JDK’s version of Java before the JRE’s. Edit
~/.bashrcand add the following lines. (Note double minus on the –list)
export JAVA_HOME=`update-alternatives –list java | sed ’s>/bin/java>>’`
- Log out and log back in again and you should now have access to the Java Development Kit and the compiler tools e.g.
- Give yourself a pat on the back!
The installation goes like a charm, except for step 10. I’ve edited my bashrc and rebooted my Pi but javac is still an unknown command. Version check worked though, so it’s definitely installed.
You’ll just have to read your path variable and see why it’s not including the correct path. Run each command (from 10) line by line to find the error.
I had to use two dashes in the - -install, - -set, and - -list commands
Thanks Maryjane. The blog article does have 2 dashes but for some reason the article renderer is condensing them into one. I tried – but they didn’t seem to work either.
I’ve updated the article to highlight the double minus instead, I hope that helps the next people.