Amazon Product List

If you are planning on purchasing any of the items listed here from Amazon, please use the links below. Using these links will provide a small contribution to maintain this site at no additional cost to you. Thank You for your support.

  • Diversitech® WS-1 - Wet Switch Flood Detector
    Diversitech® WS-1 - Wet Switch Flood Detector
  • Twine Portable Wi-Fi Sensor + Full Sensor Package
    Twine Portable Wi-Fi Sensor + Full Sensor Package
  • Getting Started with Raspberry Pi
    Getting Started with Raspberry Pi
  • 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
  • Airlink Fully compatible Wireless N 150 Ultra Mini-USB Adapter (AWLL5099)
    Airlink Fully compatible Wireless N 150 Ultra Mini-USB Adapter (AWLL5099)
  • SB Clear Raspberry Pi Enclosure
    SB Clear Raspberry Pi Enclosure
  • Raspberry Pi User Guide
    Raspberry Pi User Guide
  • 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
  • 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
  • Floodstop Individual Water Appliance Additional Water Sensor XS-01
    Floodstop Individual Water Appliance Additional Water Sensor XS-01
  • 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
  • Watts 500800 Premier Hot Water Recirculation Pump, Blue
    Watts 500800 Premier Hot Water Recirculation Pump, Blue
  • Watt'S Sensor Valve Kit for Hot Water Recirculating Pump (0955801)
    Watt'S Sensor Valve Kit for Hot Water Recirculating Pump (0955801)
  • Kicker 10cvt8-2 Shallow 8
    Kicker 10cvt8-2 Shallow 8" Subwoofer 2-ohm 400 Watts
  • Kenwood Kfc-P709Ps 6.5-Inch Performance Series Component Speaker System
    Kenwood Kfc-P709Ps 6.5-Inch Performance Series Component Speaker System
  • 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

Contributions

Contributions are very much appreciated and are used to host this website and continue to fund new DIY home automation projects. Thank You for your support.

Tuesday
Dec182012

Raspberry Pi - Installing Oracle Java Development Kit (JDK 1.7.0u10)

The Oracle JDK for ARM is now available!  This article will provide the necessary instructions on how to install the Oracle Java Development Kit (JDK) on your Raspberry Pi.  

Prerequisites

  • Install and boot the Raspberry Pi using the Debian "Wheezy" (2012-08-08 soft-float) image.  
    (The Oracle JDK is not currently compatible with the Raspian "Wheezy" image
  • Enable the Raspberry Pi for SSH remote network connections.  
    Update:  The Debian "Wheezy" image comes with SSH access enabled in the default image.
    (Here is an article on how to enable SSH in the Debian Squeeze distribution)
  • 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 Development Kit 7u10 on this page:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

First, select JDK Download button under JDK SE 7, then select the Linux ARM JDK7 SE distribution (jdk-7u10-linux-arm-sfp.gz). 

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-7u10-linux-arm-sfp.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.7.0_10" 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.7.0_10 /opt/java

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

rm ~/jdk-7u10-linux-arm-sfp.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.7.0_10/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.7.0_10/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.7.0_10"


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.7.0_10"
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 (10)

To whom it may concern:

I followed these instructions and I believe it worked when I put "java -version" in the terminal from multiple directories I recieved the expected output with version data each time. Unfortunately, when I tried to compile my first program with "javac file.java" it "busted". Please advise. Thank you.

KD7JHD

March 2, 2013 | Unregistered CommenterKD7JHD

KD7JHD, it would be hard to guess what's wrong without seeing the error messages you got from javac.

March 3, 2013 | Unregistered CommenterRusty Wright

Rusty

Thank you for helping out. My error message is "-bash: javac: command not found".

I also tried using javac in the java/jdk1.7.0_10/bin directory just in case but I recieved the same error.

"java -version" gets:
"java version "1.7.0_10
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode)"

Any idea you have are much appreciated. Thanks again.

KD7JHD

March 4, 2013 | Unregistered CommenterKD7JHD

KD7JHD, go back and re-read the java install instructions; it sounds like you missed the part about setting your PATH environment variable. The java you're getting is probably in usr bin and not the one you installed. I.e., you have two javas installed, one that came with linux, but doesn't come with javac, and the one you installed, which does, but it's missing from your path. After you fix your path I'd recommend using the linux package stuff to remove the bundled java (the one without javac) to avoid future confusion. The one you installed will stay installed.

March 4, 2013 | Unregistered CommenterRusty

Rusty

I've reviewed the instructions and reentered the commands. Based on a lack of error codes these two update-alternatives commands appear to be working. On the other hand, I do not get the message which is found in the last two lines of the second to last screenshot. It makes me wonder if the sudo promotion is working. I know that if I try to cd /root I'm denied access which is why I'm doubting the sudo temporary promotion. Thank you for your patience.

KD7JHD

March 4, 2013 | Unregistered CommenterKD7JHD

I don't have my pi yet so I can't try this. The first update-alternatives didn't provide any feedback so it's possible that the command has been changed to be less chatty; unix has had a long history of preferring commands to be quiet unless there is an error. Linux is shifting sands with its user interface; other operating systems can be more circumspect about changing the behavior of commands.

Doing a cd to a protected dir should fail since the sudo only applies to the command on the same line. I think you're ready to go.

If you want more practice installing java and linux, there are instructions out there for installing java 8 which works with rasbian and its hardware floating point; do a google search. What I saw said it was much faster.

March 5, 2013 | Unregistered CommenterRusty

i could not find the java file jdk-7u10-linux-arm-sfp.gz
i could only find jdk-7u10-linux-arm-sfp.tar.gz
any help would be much appreciated

March 12, 2013 | Unregistered CommenterAndy

Andy, the tar.gz file is what you want. Tar is a unix archive file, sort of like a zip file, but tar files are aren't compressed. You can then compress the tar file after you've created it (with the tar command) by using the gzip command, which then creates the tar.gz file. The sequence of events I use for extracting a tar.gz file is:

% gunzip whatever.tar.gz
% tar tf whatever.tar
% tar xf whatever.tar

The gunzip uncompresses it and creates the whatever.tar file, deleting the whatever.tar.gz file. The "tar tf" lists the files in the tar file; it's nice to know what it's going to create (in case someone goofed used full paths; sometimes that happens). You can ^C the "tar tf" after you've seen that the paths don't start with a / to stop it. Then the the "tar xf" extracts the files, hopefully into a directory wherever you and the tar file are. I'm old school by using the gunzip command since that's what I grew up with; newer versions of tar can do the gunzip and extraction in one step, which is what Robert is doing.

The usual recipe on unix is to do "man tar" and "man gunzip" to read their documentation and get an idea about what they do and how you use them before you run them.

March 12, 2013 | Unregistered CommenterRusty Wright

Successfully installed, but then tried to gem install rjb for ruby on rails project and got error durign compile fatal error sys/systeminfo.h: No such file or directory. Slightly off topic, but kinda related. Any ideas?

April 2, 2013 | Unregistered Commentermarvin

I am recommenting this from the older version of the article so hopefully it's seen:

Thank you for the great guide! One quick question - when I do the sudo update-alternatives --install command, after I enter it I do not get the feedback that you do above that states, "update-alternatives: using (etc..)", I simply get nothing, and then when I go to check the version it does not work. Any ideas?

May 18, 2013 | Unregistered CommenterChristopher

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 - Installing Oracle Java SE 8 (with JavaFX) Developer Preview for ARM | Main | Pi4J - Version 0.0.4 Released! »