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?
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.
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/
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
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.
/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
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
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.
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