Java 8 for Raspberry Pi Developer Preview
Oracle released the Java 8 developer preview for ARM processors last week. The build available at JDK 8 (with JavaFX) for ARM Early Access is specifically tailored for running JavaFX on Raspberry Pi devices.
While it is not a fully optimized end-customer build, it represents the current state of Java 8 in Oracle's commercial ARM version. As a developer build, its license forbids any commercial usage, but is intended to allow the Raspberry Pi community to contribute to it. However, Oracle does currently not plan to open source any parts of their ARM port, so it is questionable why any developer would donate testing time or fixes to Oracle. On the other hand, this early access build allows developers to explore options for building solutions running on Raspberry Pi and Java.
To install the build, the Raspberry Pi needs to run a up to date version of Raspbian Wheezy, which will enable using the floating point processor of the Pi. After downloading and uncompressing to the desired target directories, the binaries are fully functional. Oracle encourages developers to try running JavaFX applications. To do so, the following property needs to be passed in as command line argument:
The version information for this build is as follows:
pi@raspberrypi ~ $ /opt/jdk1.8.0/bin/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)
As this clearly states, the package defaults to a "HotSpot Client VM". Trying to force it to "Server" results in this error:
pi@raspberrypi ~ $ /opt/jdk1.8.0/bin/java -server -version Error occurred during initialization of VM Server VM is only supported on ARMv7+ VFP
One noteworthy bug of the developer preview is that only the first mouse and keyboard detected by Linux are usable by Java. This has been confirmed fixed in an upcoming buiild by Java Architect Daniel Blaukopf in the corresponding thread on the Raspberry Pi forum.
A few people already ran benchmarks on Java on Raspberry Pi. A simple prime number benchmark showed HotSpot being faster than native code, so we did our own tests using the Linpack Benchmark, which is especially targeted at floating point calculations. It of course showed that the speed of the Pi is not comparable to regular end user or server hardware.
On an i7 920 the LinPack Java Benchmark resulted in:
Mflop/s: 639.949 Time: 0.13 secs (0.131 sec) Norm Res: 5.68 Precision: 2.220446049250313E-16
While the Pi managed to get:
Mflop/s: 16.461 Time: 5.09 secs (5.093 sec) Norm Res: 5.68 Precision: 2.220446049250313E-16
For comparison of HotSpot to native code, here the results of the C version (compiled as described on ELinux Pi Performance Wiki) of the same benchmark:
Reps Time(s) DGEFA DGESL OVERHEAD KFLOPS ---------------------------------------------------- 1 0.81 97.53% 0.00% 2.47% 26687.764
But performance of the Pi is not the main reason for its popularity. As Holly Cummins showed in her Devoxx 2012 Short Talk, where she ran an application server in her hat, it spearheads a whole range of applications running on small sized standard computer hardware. A very useful addition to Java on Rasperry Pi is the Pi4J project, which provides a Java library for accessing the GPIO pins.
Mike Keane Dec 21, 2014
Jeremy Stieglitz Dec 21, 2014