27

OpenJDK compiles and runs on the Pi successfully, but the only version I've found is one without a JIT. Oracle provides such a JDK for other versions of ARM, but not ARMv6. Is there any way to get such a version of the JDK up and running in the meantime?

RLH
  • 1,965
  • 4
  • 21
  • 31
berry120
  • 10,924
  • 10
  • 51
  • 62
  • What's the distro? – Jivings Jun 12 '12 at 22:33
  • Debian squeeze at present, though I'm not overly fussed about changing if this would help the situation! – berry120 Jun 12 '12 at 22:38
  • Can you not install the OpenJDK version in the official repo? – Jivings Jun 12 '12 at 22:39
  • 1
    @Jivings Yup, that's what I'm using at the moment. But that version doesn't come with a JIT (hence the question!) – berry120 Jun 12 '12 at 22:42
  • Sorry :) I have no idea why that does not have JIT then. Seems a strange decision, have you found any rationale for it? – Jivings Jun 12 '12 at 22:43
  • 1
    @Jivings If I had to guess, I'd say it's not a trivial task to create a JIT because the optimisations are potentially somewhat different for each platform / architecture. But that's just a guess :-) – berry120 Jun 14 '12 at 10:10

6 Answers6

16

Oracle have now released (as of Java 7u6) a JDK with JIT that works on the Pi with full AWT / Swing support. It also supports JVMTI (cacao only has partial support.) Press release here.

I've verified it works with Greenfoot, and provides a huge speedup compared to the likes of a plain (non-JIT) OpenJDK build.

At the time of writing it doesn't support hard floating point, and so won't work with distributions like Raspbian that only use hard float - this is however planned for a future release.

UPDATE: As Darren pointed out, a hard float version has now been released for ARM in the form of a JDK8 preview release, you can find it here.

UPDATE 2: Hard float is now supported in JDK7.

berry120
  • 10,924
  • 10
  • 51
  • 62
7

The icedtea-6-jre-cacao package contains a JIT compiler, and reportedly works on the RasPi.

I have not tried it myself.

finnw
  • 5,790
  • 3
  • 32
  • 42
5

Oracle have now released a developer preview of Java JDK8 for ARM which specifically includes support for hard-float Raspbian on the Pi. It works, and I have found it to be around 20 times faster than OpenJDK for certain floating point intensive computations. http://jdk8.java.net/fxarmpreview/

Darren Wilkinson
  • 2,912
  • 4
  • 26
  • 27
4

On Rasbian you can use JamVM that includes a "code-copying-JIT"

apt-get install icedtea-7-jre-jamvm

JamVM is currently the fastest and most stable JVM that include a JIT on Rasbian.

Avian is also supported on Rasbian that also includes a JIT. You will have to build it manually: http://labb.zafena.se/?p=630

I expect Avian to appear in Raspbian when it have been built from Debian SID source. Avian currently exist in Debian SID experimental inside the jvm-7-avian-jre package.

Both Avian and JamVM work in combination with the OpenJDK-7 classes so you can use them both to speeding up all java launchers such as javac and java. the file /etc/java-7-openjdk/jvm-armhf.cfg determine which JVM gets used by default inside openjdk 7 on Rasbian.

You can also tell the java launchers individually which jvm to use:

java -jamvm

javac -J-jamvm
Jivings
  • 22,538
  • 11
  • 90
  • 139
2

Oracle released the full Version (no longer preview) of Java 8 and Java 7 for the ARM architecture of the Raspberry Pi: link to Java 8.

You can also use from the command line:

sudo apt-get update
sudo apt-get install oracle-java8-jdk
Simulant
  • 653
  • 1
  • 9
  • 22
1

It is possible to combine OpenJDK 7 with the JVM from Java JDK8 that includes a JIT to get a setup with X11 supported and Swing/AWT working.

The JNI interface, with "Classpath" exception, clearly separate the JVM and the runtime environment classes. If you use the Client Hotspot (jre/lib/arm/client/libjvm.so) from the JavaFX 8 preview in combination with the Rasbian compiled OpenJDK 7 Runtime environment classes and java launchers (/usr/lib/jvm/java-7-openjdk-armhf) you will get the following setup and benefits:

  • Hotspot Client JIT (from the JavaFX 8 preview)
  • Swing/AWT support (using the OpenJDK classes from the openjdk-7-jre package)
  • pulse-audio support (IcedTea pulse-java from the openjdk-7-jre and openjdk-7-jre-headless package)
  • web-browser applet support using icedtea-web (from the icedtea-7-plugin package)
  • a JNLP javaws launcher using icedtea-web (from the icedtea-7-plugin package)
  • armhf JNI autodetection by the OpenJDK java launchers (the OpenJDK java launchers adds the armhf specific system library path into java.library.path). By including the /usr/lib/arm-linux-gnueabihf path into java.library.path allows java libraries such as the Pi4J GPIO library and the JogAmp gluegen-rt JOGL/JOAL to correctly detect that it is running on a armhf linux system and then load the armhf JNI implementation instead of the armel JNI implementation.
  • Image processing and printing support inside JavaEE server applications, such as glassfish and tomcat, by using the headfull OpenJDK classes.

Setup:

Download jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz from http://jdk8.java.net/fxarmpreview/index.html

# Install openjdk-7 and the icedtea-web browser plugin
sudo apt-get install openjdk-7-jdk icedtea-7-plugin
# Extract the Oracle Client Hotspot JVM from the JavaFX 8 preview
tar --extract --verbose --file=jdk-8-ea-b36e-linux-arm-hflt-29_nov_2012.tar.gz jdk1.8.0/jre/lib/arm/client
# Place the client hotspot dir containing the libjvm.so inside the OpenJDK 7 jre/lib/arm folder
sudo mv jdk1.8.0/jre/lib/arm/client /usr/lib/jvm/java-7-openjdk-armhf/jre/lib/arm/oracle
# Configure the OpenJDK Runtime to use the Oracle client Hotspot JVM dir
# This sed command places -oracle KNOWN at the first line of jvm-armhf.cfg
sudo sed -i -e "1i\\-oracle KNOWN" /etc/java-7-openjdk/jvm-armhf.cfg

java -version
java version "1.7.0_07" <--- This is the OpenJDK 7 Update version
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2a-1+rpi1) <--- This is the   OpenJDK 7 Runtime version
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode) <--- This is the Oracle Client Hotspot JVM version
xranby
  • 361
  • 2
  • 4