precious_pony
Posts: 34
Joined: Tue May 22, 2012 11:09 pm

Java experiences?

Tue May 22, 2012 11:16 pm

Hi,

I'm a Java programmer mostly. I've been developing a lot of currently unreleased projects for the past few years (all server side code - no client GUI). I really wish to try out my code on a resource constrained environment like the PI.

I have some questions though.

How does the filesystem work on the PI. It running off the SD card right? Does that mean that if I perform file IO in my application it will be extremely slow or will the OS cache writes for me? Is the temp folder mapped to RAM or to the SD card?

I'm also curious as to the performance, and if JIT is enabled or disabled on the v6 ARM architecture.

PP

chrisg
Posts: 27
Joined: Wed Sep 21, 2011 6:41 pm
Location: Epsom, Surrey

Re: Java experiences?

Wed May 23, 2012 8:58 am

I recently ran the Dacapo benchmark suite on three different JVMs on a Raspberry Pi - I'll put the results somewhere.

If you're writing server code, try the Oracle Embedded SE JVM first. It includes a good Hotspot JIT (C1) so is reasonably fast, but it's headless only and not open.

OpenJDK has a few JIT options, including Cacao. This was roughly half the speed of the Oracle one.

I'm no expert, but Linux should do what it can to buffer writes to SD card and hold tmpfs in memory, free RAM permitting.

precious_pony
Posts: 34
Joined: Tue May 22, 2012 11:09 pm

Re: Java experiences?

Wed May 23, 2012 5:01 pm

Thanks ChrisG...

I'd love to see the results of the benchmarks, and it would be helpful if you could include the source code of the benchmarks to be able to test relative x86 performance (if they are not confidential).

chrisg
Posts: 27
Joined: Wed Sep 21, 2011 6:41 pm
Location: Epsom, Surrey

Re: Java experiences?

Wed May 23, 2012 5:54 pm

The benchmarks are here. I'll post my results when I get home.

http://dacapobench.org/

chrisg
Posts: 27
Joined: Wed Sep 21, 2011 6:41 pm
Location: Epsom, Surrey

Re: Java experiences?

Wed May 23, 2012 7:50 pm

I tested with three JVMs, using Java 6 for OpenJDK and Java 7 from Oracle. The reason for using the older OpenJDK is that I believe Cacao JIT isn't (or wasn't) yet supported on OpenJDK 7 in the standard Debian packages.

Details here:

My Pi: Debian Squeeze
Standard Debian Image - no overclocking
Linux raspberrypi 3.1.9+ #90 Wed Apr 18 18:23:05 BST 2012 armv6l GNU/Linux
Sandisk 4GB Class 6 SD Card

Benchmark
dacapo-9.12-bach.jar from http://dacapobench.org/
http://sourceforge.net/projects/dacapob ... 9.12-bach/
- excluded h2, tradebeans and tradesoap which failed on all three JVMs.
- h2 failed with OutOfMemoryError
- tradebeans and tradesoap failed with other errors (HTTP 500 response) that I did not investigate,

OpenJDK 1.6.0_18 Zero VM
java version "1.6.0_18"
OpenJDK Runtime Environment (IcedTea6 1.8.10) (6b18-1.8.10-0+squeeze2)
OpenJDK Zero VM (build 14.0-b16, mixed mode)
Command: java -server -ms128m -mx128m -jar dacapo-9.12-bach.jar <suite>
  • avrora: 1170648ms
    batik: 231197ms
    eclipse: 4521264ms
    fop: 167553ms
    jython: 2220869ms
    luindex: 278886ms
    lusearch: 1168154ms
    pmd : 390798ms
    sunflow: 4822182ms
    tomcat: FAIL – HTTP 500 response code (did not investigate further)
    xalan: 1381904ms


OpenJDK 1.6.0_18 Cacao VM
java version "1.6.0_18"
IcedTea Runtime Environment (IcedTea6 1.8.10) (6b18-1.8.10-0+squeeze2)
CACAO (build 0.99.4, compiled mode)
Command: java -cacao -ms128m -mx128m -jar dacapo-9.12-bach.jar <suite>
  • avrora: 369048ms
    batik: FAIL – OutOfMemoryError
    eclipse: FAIL – "Unable to acquire service".
    fop: 77898ms
    jython: FAIL – NullPointerException
    luindex: 62681ms
    lusearch: 513202ms
    pmd : 277703ms
    sunflow: 5958856ms
    tomcat: FAIL – VM Segfault
    xalan: 454358ms
Oracle 1.7.0_04 Embedded VM (C1)
java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment for Embedded (build 1.7.0_04-ea-b20, headless)
Java HotSpot(TM) Embedded Client VM (build 23.0-b21, mixed mode)
Command: java -ms128m -mx128m -jar dacapo-9.12-bach.jar <suite>
  • avrora: 227892ms
    batik: 75714ms
    eclipse: FAIL – OutOfMemoryError in PermGen (could probably fix easily with a CLI option)
    fop: 52090ms
    jython: 356334ms
    luindex: 44519ms
    lusearch: 194130ms
    pmd : 123855ms
    sunflow: 339214ms
    tomcat: 124153ms
    xalan: 218426ms

rfincher1
Posts: 13
Joined: Sat May 26, 2012 5:09 am

Re: Java experiences?

Mon Jul 23, 2012 4:29 am

[quote="chrisg"]I tested with three JVMs, using Java 6 for OpenJDK and Java 7 from Oracle. The reason for using the older OpenJDK is that I believe Cacao JIT isn't (or wasn't) yet supported on OpenJDK 7 in the standard Debian packages.


Hi Chris,

How did you get the Oracle embedded headless JVM installed? I installed the files on the Pi in /usr/share and setup JAVA_HOME and added the path to /usr/binbin.

When I sudo java -version I get: java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

The file exists under /usr/share/java/lib/arm/jli. Any idea what I'm doing wrong?

Thanks!

rfincher1
Posts: 13
Joined: Sat May 26, 2012 5:09 am

Re: Java experiences?

Mon Jul 23, 2012 4:54 am

rfincher1 wrote:
Hi Chris,

How did you get the Oracle embedded headless JVM installed? I installed the files on the Pi in /usr/share and setup JAVA_HOME and added the path to /usr/binbin.

When I sudo java -version I get: java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

The file exists under /usr/share/java/lib/arm/jli. Any idea what I'm doing wrong?

Thanks!
Some others have run into the same problem under Raspbian. It looks like there an incompatiblity in Raspbian with the Oracle embedded JVM, for now anyway.

Rick

stefangs
Posts: 7
Joined: Sat Jul 28, 2012 9:48 pm

Re: Java experiences?

Sun Jul 29, 2012 8:03 pm

Ok, I am getting a bit annoyed by now. I have spent quite some time trying to get a working Java- environment running on Raspbian – and failed miserably.

I have tried building JamVM – this failed when building the needed GNU Classpath-library (0.99), “./configure“ did not create a Makefile, so I could not build it.

I tried using the Oracle SE Embedded (1.7.0_04), but ran in to the same problem as described above (libjli.so: cannot open shared object file) - Fail

So, I tried the openjdk 6. With the ZeroVM (build 20.0-b12, mixed mode) it actually works, but the performance without JIT is simply too bad for any serious usage. I then tried the Cacao-VM (build 1.1.0pre2, compiled mode) which should be faster, but it fails to start my application, stating it cannot find the main class, caused by: java.lang.IllegalArgumentException: disparate values (the same .jar works with ZeroVM).

I finally tried openjdk 7, but the package manager could not find it.

So, could someone PLEASE give me some concrete hints on how to actually get a working Java environment on the Pi, before I have to give up this platform entirely?

User avatar
aquarat
Posts: 73
Joined: Thu Jul 26, 2012 2:32 pm
Location: Cape Town, South Africa

Re: Java experiences?

Mon Jul 30, 2012 7:16 am

The Raspberry Pi is an extremely cheap and versatile machine. It's good value for money and fun, so I'm prepared to spend a bit more time getting stuff working on it.

That said, I didn't have to do anything out of the ordinary to get Java working. I flashed Raspbian to a 32GB SDHC card and then I installed openjdk-6-jre. I also compiled both MariaDB and the Phidget USB drivers. I haven't had any issues.

So far performance has exceeded that of a similar installation on a PCEngines Alix board (x86) which costs almost three times the price.

I'd suggest starting over with a fresh Raspbian image and then installing openjdk-6-jre. I'd run programmes with the "-server" argument and I'd make sure that the system is configured to give Linux as much RAM as possible.

Good luck
EOF

stefangs
Posts: 7
Joined: Sat Jul 28, 2012 9:48 pm

Re: Java experiences?

Wed Aug 01, 2012 8:34 pm

Thanks, I did not mean to sound bitter. I know a lot of people are working hard making things work on RaspberryPi and are dedicating a lot of their spare time for free. I also think the Raspbian distribution is very stable and complete – well done! That said, I still have some issues, mainly regarding information. What I have understood after a lot of googling and trying is this:

The Raspbian distribution is compiled for using ARM’s hardware support for floating point calculations. Unfortunately the Oracle distribution of JVM for ARM is compiled for using software floating point calculations which simply means that the Oracle JVM currently cannot work on Raspbian distribution.

The problem here is performance. The JVM you are suggesting (openjdk with -server option) is a completely interpreted java throwing us years back in time in performance, and on a limited hardware like this the result is very poor.

I am far from a Linux expert, but I used another (far less complete) Debian distribution which is compiled with the soft float option where I could compare the performance. I am building a home automation system, which has a simple WEB-interface and I just compared the time of loading the main page in the application. The result is this:

With openjdk –server: 2.7 Seconds
With openjdk –cacao (semi JIT version that does not work on Raspbian): 1.3 Seconds
With Oracle JVM: 0.6 Seconds

The difference in user experience is enormous – almost 3 seconds per page for a local app feels almost unusable while 0.6 seconds is like running it on an ordinary PC! The Oracle VM is more than four times faster in the real world for this application, its like running the Pi on 2.8GHz with openjdk!

So to give the advise to use the openjdk is almost like killing the RasperryPi as a Java platform – anyone trying to run any non console based, real world application is bound to be disappointed and draw the conclusion that RaspberryPi is not usable for java, while in reality it is actually possible to get really good java performance!

The distribution I found was very limited, so could someone please recommend a stable debian distribution with a downloadable image for RaspberryPi that is compiled with soft floating point that can be used for running the Oracle JVM?

dacha
Posts: 11
Joined: Sun Jun 17, 2012 4:35 pm

Re: Java experiences?

Thu Aug 02, 2012 8:44 pm

stefangs wrote:Thanks, I did not mean to sound bitter. I know a lot of people are working hard making things work on RaspberryPi and are dedicating a lot of their spare time for free. I also think the Raspbian distribution is very stable and complete – well done! That said, I still have some issues, mainly regarding information. What I have understood after a lot of googling and trying is this:

The Raspbian distribution is compiled for using ARM’s hardware support for floating point calculations. Unfortunately the Oracle distribution of JVM for ARM is compiled for using software floating point calculations which simply means that the Oracle JVM currently cannot work on Raspbian distribution.

The problem here is performance. The JVM you are suggesting (openjdk with -server option) is a completely interpreted java throwing us years back in time in performance, and on a limited hardware like this the result is very poor.

I am far from a Linux expert, but I used another (far less complete) Debian distribution which is compiled with the soft float option where I could compare the performance. I am building a home automation system, which has a simple WEB-interface and I just compared the time of loading the main page in the application. The result is this:

With openjdk –server: 2.7 Seconds
With openjdk –cacao (semi JIT version that does not work on Raspbian): 1.3 Seconds
With Oracle JVM: 0.6 Seconds

The difference in user experience is enormous – almost 3 seconds per page for a local app feels almost unusable while 0.6 seconds is like running it on an ordinary PC! The Oracle VM is more than four times faster in the real world for this application, its like running the Pi on 2.8GHz with openjdk!

So to give the advise to use the openjdk is almost like killing the RasperryPi as a Java platform – anyone trying to run any non console based, real world application is bound to be disappointed and draw the conclusion that RaspberryPi is not usable for java, while in reality it is actually possible to get really good java performance!

The distribution I found was very limited, so could someone please recommend a stable debian distribution with a downloadable image for RaspberryPi that is compiled with soft floating point that can be used for running the Oracle JVM?
Give Avian a try (http://oss.readytalk.com/avian/index.html). You'll have to check it out of Git and compile it, but it works well on Raspbian as of a few days ago (https://groups.google.com/forum/#!topic ... nz4JZEPwZs), and it has a JIT that's a lot faster than OpenJDK's Zero (5-10 times faster in my SciMark2 benchmarks). It's also able to use OpenJDK as its class library instead of the incomplete built-in class library it ships with, but for that it needs OpenJDK7 installed, which isn't in Raspbian's repository yet. This could be fixed quite easily though.

There was some talk of patching JamVM to support Raspbian. Otherwise CACAO could be patched, and there is still at least GCJ, IKVM.NET, and VMKit J3 to consider from the open-source JVMs.

User avatar
freedomotic
Posts: 154
Joined: Sat Apr 21, 2012 3:59 pm
Location: Italy
Contact: Website

Re: Java experiences?

Sun Aug 05, 2012 5:31 pm

Hi, we are trying to use avian for our domotic framework but it needs openjdk 7 and unfortunately the openjdk that is available on the raspbian is the 6. So it doesn't compile.
Can you help me to solve the problem?
Thanks
Freedomotic Open IoT Framework
http://freedomotic.com

dacha
Posts: 11
Joined: Sun Jun 17, 2012 4:35 pm

Re: Java experiences?

Sun Aug 05, 2012 5:37 pm

freedomotic wrote:Hi, we are trying to use avian for our domotic framework but it needs openjdk 7 and unfortunately the openjdk that is available on the raspbian is the 6. So it doesn't compile.
Can you help me to solve the problem?
Thanks
Raspbian does have OpenJDK 7 as of a few days ago :) .

night57
Posts: 3
Joined: Mon Aug 06, 2012 1:38 pm

Re: Java experiences?

Mon Aug 06, 2012 2:44 pm

Can anyone please tell me how to compile Avian on RPi? I tried many times, but i always got some error (jni.h not found, lto-wrapper failed...).

dacha
Posts: 11
Joined: Sun Jun 17, 2012 4:35 pm

Re: Java experiences?

Mon Aug 06, 2012 4:15 pm

night57 wrote:Can anyone please tell me how to compile Avian on RPi? I tried many times, but i always got some error (jni.h not found, lto-wrapper failed...).
lto-wrapper fails because you don't have enough free disk space in /tmp.
This can be fixed by remounting it with a bigger size, using something like this:

Code: Select all

mount /tmp -o remount,rw,nosuid,nodev,relatime,size=37616k

night57
Posts: 3
Joined: Mon Aug 06, 2012 1:38 pm

Re: Java experiences?

Mon Aug 06, 2012 5:10 pm

That fixed it. Thanks. Now i have problem this problem with jni.h missing. I thought i should get those files in OpenJDK sources but i have not been able to find them there. Does anyone know how to fix this?

Code: Select all

compiling build/linux-arm/java-lang.o
classpath/java-lang.cpp:10:17: fatal error: jni.h: No such file or directory
compilation terminated.
make: *** [build/linux-arm/java-lang.o] Error 1

dacha
Posts: 11
Joined: Sun Jun 17, 2012 4:35 pm

Re: Java experiences?

Mon Aug 06, 2012 5:15 pm

night57 wrote:That fixed it. Thanks. Now i have problem this problem with jni.h missing. I thought i should get those files in OpenJDK sources but i have not been able to find them there. Does anyone know how to fix this?

Code: Select all

compiling build/linux-arm/java-lang.o
classpath/java-lang.cpp:10:17: fatal error: jni.h: No such file or directory
compilation terminated.
make: *** [build/linux-arm/java-lang.o] Error 1
How are you compiling it? You are meant to use:

Code: Select all

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-armhf make
or if you want OpenJDK as your class library (a good idea):

Code: Select all

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-armhf make openjdk=/usr/lib/jvm/java-7-openjdk-armhf
This is, of course, after installing the openjdk-7-jdk package.

stefangs
Posts: 7
Joined: Sat Jul 28, 2012 9:48 pm

Re: Java experiences?

Mon Aug 06, 2012 8:46 pm

I am continuing to try to get java running with good performance and all features, but I am not there yet.
I would like to avoid having to build the JVM, since I want to have easy installation instructions for users of my software.
I have tried a lot of combinations, and the closest ones to work so far are:
  • Openjdk-7 with Zero JVM on raspian: works well with all features including sound and rxtx – but it is VERY slow
  • Openjdk-7 with CACO JVM on raspian: Now *almost* works. Stops with an unspecified IOException as soon as you try to open a file.
  • Oracle JVM 7 on debian wheezy-beta: Works with really good performance, but does not find any sound sources!
  • Oracle JVM 7 on Arch Linux: Works with really good performance, but does not find any sound sources!
Does anybody know why the Oracle JVM cannot find the sound card? I see the sound card (a USB-card) when I run alsamixer, so it is detected and working in Linux, but my Java-program cannot find it (except when running openjdk on raspian).

dacha
Posts: 11
Joined: Sun Jun 17, 2012 4:35 pm

Re: Java experiences?

Tue Aug 07, 2012 7:54 am

stefangs wrote:I am continuing to try to get java running with good performance and all features, but I am not there yet.
I would like to avoid having to build the JVM, since I want to have easy installation instructions for users of my software.
Avian also allows you to compile your Java application into a standalone binary that doesn't need a JVM to run, and is thus even easier for users to install. I haven't tested this yet though. If you do, please let us know the results.

Edit: and GCJ also works and even outperforms Oracle's Java SE Embedded in my tests. You should use:

Code: Select all

sudo apt-get install gcj-4.6
gcj-4.6 myapp.jar -o myapp -O2 -mfpu=vfp
./myapp

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Java experiences?

Tue Aug 07, 2012 8:56 am

Ummm GCJ sounds nice. I'm installing 4.4 on a netbook to test.
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

night57
Posts: 3
Joined: Mon Aug 06, 2012 1:38 pm

Re: Java experiences?

Wed Aug 08, 2012 8:48 am

dacha wrote:

Code: Select all

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-armhf make openjdk=/usr/lib/jvm/java-7-openjdk-armhf
This way i was able to compile it succesfully, but after trying to launch simple .jar file i receive

Code: Select all

java/lang/UnstatisfiedLinkError: library not found: libverify.so
The same .jar works without problem in OpenJDK.

dacha
Posts: 11
Joined: Sun Jun 17, 2012 4:35 pm

Re: Java experiences?

Wed Aug 08, 2012 9:21 am

night57 wrote:
dacha wrote:

Code: Select all

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-armhf make openjdk=/usr/lib/jvm/java-7-openjdk-armhf
This way i was able to compile it succesfully, but after trying to launch simple .jar file i receive

Code: Select all

java/lang/UnstatisfiedLinkError: library not found: libverify.so
The same .jar works without problem in OpenJDK.
I really need a wiki or something to keep track of how to get different JVMs working on the RPi...

Update your Git to the latest version, recompile, and make sure you launch it like the readme.txt says:

Code: Select all

LD_LIBRARY_PATH=/path/to/avian.git/build/avian-arm-openjdk /path/to/avian.git/build/avian-arm-openjdk/avian-dynamic -jar /path/to/file.jar

stefangs
Posts: 7
Joined: Sat Jul 28, 2012 9:48 pm

Re: Java experiences?

Sat Aug 11, 2012 9:19 pm

Well, I am still trying to get Oracle Java to run properly on Arch Linux, but have not succeeded completely yet... I run this small test program:

Code: Select all

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Mixer;

public class TestMixers {
    static public void main(String[] args) {
        Mixer.Info mixers[] = AudioSystem.getMixerInfo();
        System.out.println("Found " + mixers.length + " mixers");
        for (int i = 0; i < mixers.length; i++) {
            System.out.println("Mixer " + i + ":" + mixers[i].getName());
        }
    }
}
When I run this with OpenJDK it finds 3 mixers (including the USB sound card I want to use), but when I run the same code with Oracle JVM (1.7.0_04-b20 or 1.6.0_32-b05) it does not find any mixers at all. Has anyone managed to get sound working on RPi with Oracle JVM?

Howard
Posts: 64
Joined: Sun Mar 04, 2012 7:38 pm
Contact: Website

Re: Java experiences?

Sun Aug 12, 2012 6:36 pm

There have been a couple of suggestions to try Avian with OpenJDK-7.
Now Avian on its own has a minimal library and hence of rather limited use.
Question: Is Avian+OpenJDK-7 still Headless?
If so that is still no use to me. All the Pi projects I want to do need a GUI.

Stefangs wrote:
I am continuing to try to get java running ... Openjdk-7 with CACO JVM *almost* works.
I guess this is the most likely path to JIT+swing??

User avatar
jackokring
Posts: 816
Joined: Tue Jul 31, 2012 8:27 am
Location: London, UK
Contact: ICQ

Re: Java experiences?

Fri Sep 21, 2012 10:51 pm

I have installed default-jdk (seems to be openjdk6, matching jre as used by openoffice.org) and eclipse. It takes a while to load, and uses about 50.5% of the memory with the default raspbian split, and no sources loaded, just the welcome screen.

I also installed ecj-gcj package for later compilation usage to native.

I don't need the version 7 features, and I'm more interested in JogAmp JOGL as used by the scilab package. The full JogAmp kit also looks as if it does audio abstraction, and has a window toolkit independent of AWT and Swing.

I love the -X switch on ssh, and I wonder if the startx& is necessary...
Pi[NFA]=B256R0USB CL4SD8GB Raspbian Stock.
Pi[Work]=A+256 CL4SD8GB Raspbian Stock.
My favourite constant 1.65056745028

Return to “Other programming languages”