Showing posts with label JDK8. Show all posts
Showing posts with label JDK8. Show all posts

Sunday, August 3, 2014

Install JDK 8 on Raspberry Pi and set JAVA_HOME and PATH


Updated@2015-03-24:
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: http://www.oracle.com/technetwork/java/javase/downloads/index.html, 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
  • 192.168.1.104 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@192.168.1.104:

Log-in Raspberry Pi via ssh:
$ ssh -X 192.168.1.104 -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.



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

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

Sunday, February 9, 2014

Java 8 release candidate is available (with steps to install on Raspberry Pi)

As announced in the post "Update on JDK 8 builds and release candidate status", the first release candidate build of JDK 8, b128 is available on https://jdk8.java.net/download.html. Including supported platform of Linux ARMv6/7 VFP, HardFP ABI, it can be run on Raspberry Pi. Here show the steps to install on Raspberry Pi.

In the steps shown here, visit https://jdk8.java.net/download.html on host PC, click to Accept License Agreement to get the actually download link of Linux ARMv6/7 VFP, HardFP ABI, it's http://www.java.net/download/jdk8/archive/b128/binaries/jdk-8-fcs-b128-linux-arm-vfp-hflt-31_jan_2014.tar.gz currently for Build b128.

JDK8 Download page
https://jdk8.java.net/download.html
Run on LXTerminal in Raspberry Pi:

  • Enter the command to downlaod the tar.gz with wget:
    wget --no-check-certificate http://www.java.net/download/jdk8/archive/b128/binaries/jdk-8-fcs-b128-linux-arm-vfp-hflt-31_jan_2014.tar.gz
  • Un-compress the downloaded tar.gz:
    sudo tar zxvf jdk-8-fcs-b128-linux-arm-vfp-hflt-31_jan_2014.tar.gz -C /opt
    The un-compressed jdk8 will be install in /opt/jdk1.8.0
  • To set the new JDK8 as default java and javac, enter the command:
    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

    Run the following commands to select jdk8 as default java:
    sudo update-alternatives --config javac
    sudo update-alternatives --config java
  • Now you can run the commands to verify default jdk version:
    $ java -version
    $ javac -version



After installed, you can create a test program to list System Properties to verify the installation.

Monday, December 2, 2013

Set JDK8 as default java and javac with alternatives

Last post show how to "Install JDK8 Early Access Releases on Raspberry Pi". You can varify installation of the new JDK8 by enter the command:
$ /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)

means you have install JDK1.8.0 successfully. But when you enter the command without specifying path:
$ java -version
$ javac -version

It will show the version of the original version, may be 1.7.0_40.

In order to make the new JDK8 as default java and javac, we can run update-alternatives.

- In order to run update-alternatives on Raspberry Pi, we have to "Set password of root", such that we can log-in as root by the command and password:
$su

Then run the commands:
$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

Run the commands to select the expected Java.
$sudo update-alternatives --config javac
$sudo update-alternatives --config java




You can verify your setting by run the Java example in next post to List system properties.

Install JDK8 Early Access Releases on Raspberry Pi

This post show how to download and install JDK8 Early Access Releases on Raspberry Pi.

The page https://jdk8.java.net/download.html provide download link of JDK 8 Early Access Releases for various platforms, include JDK of Linux ARMv6/7 VFP, HardFP ABI which can be run on Raspberry Pi. You have to check to accept Accept License Agreement to view the ownload link, currently http://www.java.net/download/jdk8/archive/b117/binaries/jdk-8-ea-b117-linux-arm-vfp-hflt-20_nov_2013.tar.gz.

JDK8 Early Access Releases
JDK8 Early Access Releases
In my approach, log-in Raspberry Pi via ssh, and download using wget. In order to ignore server's certificate in wget, option of --no-check-certificate have to be added.
$ wget --no-check-certificate http://www.java.net/download/jdk8/archive/b117/binaries/jdk-8-ea-b117-linux-arm-vfp-hflt-20_nov_2013.tar.gz

After downloa, run the command:
sudo tar zxvf jdk-8-ea-b117-linux-arm-vfp-hflt-20_nov_2013.tar.gz -C /opt

The JDK will be installed in /opt/jdk1.8.0/bin/


Next:
Set JDK8 as default java and javac with alternatives