Contributions

Contributions are appreciated and used to host this site. Thank You for your support.

Feature Products
  • Raspberry Pi with Java: Programming the Internet of Things (IoT)
    Raspberry Pi with Java: Programming the Internet of Things (IoT)
  • Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU
    Raspberry Pi 2 Model B Project Board - 1GB RAM - 900 MHz Quad-Core CPU
  • Premium Clear Case for Raspberry Pi 2 Model B Quad Core and Raspberry Pi Model B+ (B PLUS)
    Premium Clear Case for Raspberry Pi 2 Model B Quad Core and Raspberry Pi Model B+ (B PLUS)
  • Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard
    Edimax EW-7811Un 150 Mbps Wireless 11n Nano Size USB Adapter with EZmax Setup Wizard
  • Getting Started with Raspberry Pi
    Getting Started with Raspberry Pi
  • Raspberry Pi User Guide
    Raspberry Pi User Guide
  • PiBrella LED Add On Board
    PiBrella LED Add On Board
  • Diversitech® WS-1 - Wet Switch Flood Detector
    Diversitech® WS-1 - Wet Switch Flood Detector
  • Onsite Pro FS1NPTW Whole Home Wireless FloodStop with 1 Inch Valve
    Onsite Pro FS1NPTW Whole Home Wireless FloodStop with 1 Inch Valve
  • Floodstop Washing Machine Valve Shutoff Kit
    Floodstop Washing Machine Valve Shutoff Kit
  • Onsite Pro FS3/4H Washing Machine FloodStop with Straight Valves
    Onsite Pro FS3/4H Washing Machine FloodStop with Straight Valves
  • Floodstop Individual Water Appliance Additional Water Sensor XS-01
    Floodstop Individual Water Appliance Additional Water Sensor XS-01
  • Aqua Managers - FS 1 1/4-NPT - Floodstop for Water Heaters Water Leak Detection System - White - 1.25 in. pipe
    Aqua Managers - FS 1 1/4-NPT - Floodstop for Water Heaters Water Leak Detection System - White - 1.25 in. pipe
  • Furman MP-20 Power Relay Accessory, 20 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
    Furman MP-20 Power Relay Accessory, 20 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
  • Furman MP-15 Power Relay Accessory, 15 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
    Furman MP-15 Power Relay Accessory, 15 Amp, Two Outlets, Remote Turn-on from Momentary or Maintained Contact Switches
  • Metra 70-2002 Radio Wiring Harness for Saturn 00-05
    Metra 70-2002 Radio Wiring Harness for Saturn 00-05
  • Metra Reverse Wiring Harness 71-2002 for Select 2000-2005 Saturn Vehicles OEM Radio
    Metra Reverse Wiring Harness 71-2002 for Select 2000-2005 Saturn Vehicles OEM Radio
Tuesday
Dec182012

Raspberry Pi - Installing Oracle Java SE 8 (with JavaFX) Developer Preview for ARM

The Oracle JDK8 for ARM with support for hard-float ABI is now available as a developer preview edition!  This article will provide the necessary instructions on how to install the Oracle Java SE 8 (with JavaFX) Developer Preview for ARM on your Raspberry Pi.  

Prerequisites

  • Install and boot the Raspberry Pi using the latest Raspbian "Wheezy" (2012-12-16-wheezy-raspbian.zip) image.  
    (This is the first Oracle JDK compatible with the Raspian "Wheezy" image
  • Get the Raspberry Pi's IP address.

Tools & Downloads:

All:

Windows:

Mac-OSX:

Download the Oracle JDK for the Raspberry Pi

You can download the Oracle Java SE 8 (with JavaFX) Developer Preview for ARM on this page:
http://jdk8.java.net/fxarmpreview/

Transfer the Oracle JDK to the Raspberry Pi

After downloading the Oracle JDK to you desktop computer, we need to transfer it over to the Raspberry Pi.  We will use SCP to transfer the file over the network.  If you are running on a Windows desktop, then download and install WinSCP.

 If you are using Mac OSX, you can download and install Cyberduck.  The screens will look different but the goals are the same.

Create a new session in WinSCP using the IP address of you Raspberry Pi.  The default authentication credentials for the Debian Squeeze image is username "pi" and password "raspberry".  Save the session and then login.  You may be prompted to accept the SSH fingerprint, choose "Yes" to accept and continue.

After successfully establishing a connection, select the drive and folder location in the left pane where you download the Oracle JDK file to on your local desktop system.  In the right pane is the file system on the Raspberry Pi, we will leave it in it's default location in the "pi" user's home directory.  Drag and drop the Oracle JDK file from the left pane to the right pane and WinSCP will start the file transfer process.  You will be prompted with a transfer dialog, just click the "Copy" button to start the transfer.  


When the file transfer is complete, you can close WinSCP (or CyberDuck).

Installation Procedure on Raspberry Pi

The remaining steps should be performed directly on the console of the Raspberry Pi or using a SSH terminal connection with shell access.  In the last step, we transfered the Oracle JDK file to the "pi" user's home directory.  We should be logged in as the "pi" user and already in the user's home directory.

Lets create a new directory where we will install the JDK files to. 

sudo mkdir -p -v /opt/java

Next, lets unpack the Oracle JDK .gz file using this command

tar xvzf ~/jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz

The unpacking process will take a few seconds to complete.  It unpacks all the contents of the Oracle JDK tz file to a new directory named "jdk1.8.0" located in the user's home directory.

With the unpack complete its now time to move the new unpacked directory to the Java install location that we created earlier under "opt/java".  

sudo mv -v ~/jdk1.8.0 /opt/java

We can also delete the original .gz file as it is no longer needed 

rm ~/jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz

To complete the JDK installation we need to let the system know there is a new JVM installed and where it is located.  Use the following command to perform this task.

sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/jdk1.8.0/bin/java" 1

And finally we also need to tell the system that we want this JDK to be the default Java runtime for the system. The following command will perform this action.

sudo update-alternatives --set java /opt/java/jdk1.8.0/bin/java

Now java is installed.  To test and verify we can execute the java command using the version argument.

java -version

You should get the following response:

That's it the Oracle JDK is installed and ready for use.

Add JAVA_HOME Environment Variable

Some Java programs require a JAVA_HOME environment variable to be configured on the system.  Add the following line to you "/etc/environment" using your favorite text editor.

JAVA_HOME="/opt/java/jdk1.8.0"


Also, edit your "~/.bashrc" file using this command

nano ~/.bashrc

and add the following two lines to the bottom of the file and save.

export JAVA_HOME="/opt/java/jdk1.8.0"
export PATH=$PATH:$JAVA_HOME/bin 


Reboot or re-login to apply the export to your environment.  

* Raspberry Pi is a trademark of the Raspberry Pi foundation.
* Oracle and Java are registered trademarks of Oracle.

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (21)

Great post. Thanks. Clear, concise and it work.

January 23, 2013 | Unregistered CommenterJohn

@John,

Thanks and glad it was helpful!
Robert

January 23, 2013 | Registered CommenterRobert Savage

WILL NOT LET ME CHANGE THE ENVIRONMENT FILE! HELP

February 16, 2013 | Unregistered CommenterWindFreaker

@WindFreaker,

Make sure you use the "sudo" command to open the editor to make changes to the "/etc/environment" file.

February 16, 2013 | Registered CommenterRobert Savage

Why not downloading the java directly from Rpi?

Copy the link to java file from http://jdk8.java.net/fxarmpreview/

On Rpi just execute:

wget <link_to_java_download>

at 6 March i was:

wget http://www.java.net/download/JavaFXarm/jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz

March 6, 2013 | Unregistered Commentertwk

I discovered that to run the examples provided by oracle from the command line, you need to include jfxrt.jar in the classpath

This is critical as of course you can't run them from the rpi default browser

March 16, 2013 | Unregistered Commenterpwallis

Robert, do you have tomcat set up so that it starts when the system boots? If so, how are you doing that. Not sure if your setup would help me since I'm running Arch Linux, but I thought I'd ask.

March 24, 2013 | Unregistered CommenterRusty Wright

@Rusty,

Sorry, I have not setup Tomcat on my Pi yet :-)
I have setup some autostart stuff in the past by using the init.d scripts in Debian.

-Robert

March 25, 2013 | Registered CommenterRobert Savage

Thanks for the tutorial, seems to work just fine :-)

On my machine, I don'y know why but the java --version command line didn't work, but only when I used only one dash : java -version :

pi@raspberrypi /usr/src $ java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
pi@raspberrypi /usr/src $ java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b36e)
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode)

March 29, 2013 | Unregistered CommenterBruno Perel

Hi! I also got it to work.

But I do not know how to get to "/etc/environment" and make the changes there.

Could somebody but the commands here?

April 16, 2013 | Unregistered CommenterAndras

Try : "sudo nano /etc/environment" to edit the file.

April 16, 2013 | Registered CommenterRobert Savage

Brilliant!! This worked first time as written where all the other posts I saw failed

thank you

May 5, 2013 | Unregistered CommenterJames Turner

whole installation went fine. However, im little confused, trying to compile any file i'm getting: javac - command not found. How can i get it works ?

May 16, 2013 | Unregistered Commentertachycardian

Sounds like you missed the export command(s) where you set your PATH. Or didn't logout and log back in.

May 16, 2013 | Unregistered CommenterRusty Wright

what do i do next? D: i realize there isn't much articles / resources on openremote. i hope you can write more :)

June 5, 2013 | Unregistered Commenteryvonnezoe

Thanks for your guide, unfortunately I'm stuck at the end somehow my java version seems not be recognized:

pi@raspberrypi ~ $ java -version
-bash: /usr/bin/java: No such file or directory

June 23, 2013 | Unregistered CommenterDaniel

for daniel the path is /opt/java/jdk1.8.0/bin/java not /usr/bin/java that is pi@raspberrypi ~ $/opt/java/jdk1.8.0/bin/java -version
for Bruno Perel the command has only one line java -version not java --version

August 2, 2013 | Unregistered Commentermanuel

Thanks a lot, worked like a charm! Launched Tomcat 7 and everything seems to work fine!

August 23, 2013 | Unregistered CommenterThierry

Ok guys, the install is done.

pi@raspi ~ $ sudo /opt/jdk1.8.0/bin/java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b117)
Java HotSpot(TM) Client VM (build 25.0-b59, mixed mode)

But then, when I look for the java default version, i get
pi@raspi ~ $ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode)

In an other blog, i found the following command to ad
pi@raspi ~ $ sudo update-alternatives --set java /opt/jdk1.8.0/bin/java
update-alternatives: error: alternative /opt/jdk1.8.0/bin/java for java not registered; not setting

What is wrong here ?

December 8, 2013 | Unregistered Commenterspinout

I did all that on my Pi an then built a simple hello worl javafx app on netbeans using jdk1.8 on my windows machine, transfered the jar file and run on pi , it says
Could not find or load main class -Djava.ext.dirs=.home.pi.armv6hf-sdk.rt.lib.ext

January 26, 2017 | Unregistered CommenterSingh

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
« Raspberry Pi - SB Clear Raspberry Pi Enclosure | Main | Raspberry Pi - Installing Oracle Java Development Kit (JDK 1.7.0u10) »