Java on Raspbian


106 posts   Page 1 of 5   1, 2, 3, 4, 5
by acobley » Wed Jul 18, 2012 8:50 pm
I'm trying to get java (Java SE Embedded 6 http://www.oracle.com/technetwork/java/ ... index.html) running on Raspbian. However when I try and run it, I'm getting :

java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

I've previously had this version running on Debian-Squeeze but I'm sure I didn't see this error. I'm sure I've the PATH and JAVA_HOME set correctly

Any ideas ?

BTW I'm not using openjdk because in tests for my application it was a lot slower.

Andy
Blog: http://ac31004.blogspot.co.uk/
Posts: 20
Joined: Fri Feb 10, 2012 9:54 am
by mpthompson » Wed Jul 18, 2012 9:54 pm
acobley wrote:Any ideas ?


Andy, looking at what's available at that site, I don't see any binaries that are supported by Raspbian. The armv6 binaries use the soft float ABI (armel) which is incompatible with Raspbian. Even their armv7 binaries use the soft float ABI which I find a little curious, but there is probably a good reason for that from their perspective.

I live about two miles from the Oracle headquarters in Redwood Shores, CA and I would be happy to see what I could to help them create armv6 hard float ABI (armhf) binaries that would run under Raspbian, but someone would have to contact Oracle to see if there is interest on their behalf.
User avatar
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA
by acobley » Thu Jul 19, 2012 8:16 am
Thats a real shame !

I'll do some tests with openjdk but in the past I've found that a lot slower than the Oracle java. This could be quite a pain, may have to go back to the Debian image.

It would be nice f oracle would take some interest in the Pi.


Andy
Posts: 20
Joined: Fri Feb 10, 2012 9:54 am
by freedomotic » Thu Jul 19, 2012 8:41 pm
Hi Andy,
the embedded oracle jvm isn't free? Do you know how much it's the required royalty?
We are doing some tests for our domotic framework and openjdk is very slow on raspi and debian wheezy.
Thanks
Freedomotic Open Source Building Automation
http://freedomotic.com
User avatar
Posts: 151
Joined: Sat Apr 21, 2012 3:59 pm
Location: Italy
by mpthompson » Thu Jul 19, 2012 8:52 pm
I would encourage someone to take the initiative to contact Oracle and see what they have to say about creating a set of JRE binaries that support armv6+vfp. If the response was favorable, I would do what I could to help with such an effort. I've just got too much on my plate to do it myself right now. The chances of a positive response are pretty slim, but you never know where serendipity might take you.
User avatar
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA
by freedomotic » Thu Jul 19, 2012 8:56 pm
Hi, do you have a reference (mail, person) to contact in Oracle?
Have you ever try to contact them?
Freedomotic Open Source Building Automation
http://freedomotic.com
User avatar
Posts: 151
Joined: Sat Apr 21, 2012 3:59 pm
Location: Italy
by asb » Thu Jul 19, 2012 9:02 pm
You'll likely find better performance with cacaovm if you're able to use it. See these performance measurements by Xerxes Ranby: https://docs.google.com/spreadsheet/oim ... o09v1y3q53

We (the Raspberry Pi Foundation) have been in contact with Oracle and other JVM providers.
Forum Moderator
Forum Moderator
Posts: 851
Joined: Fri Sep 16, 2011 7:16 pm
by acobley » Fri Jul 20, 2012 2:59 pm
So, out of interests, what would the Java jvm need to be compiled with ? I note that Java SE Embedded 6 on ARM EABI, Little-Endian, Linux is compiled with the options :

gcc options used include: -mfloat-abi=softfp -mfpu=vfp

Andy
Posts: 20
Joined: Fri Feb 10, 2012 9:54 am
by darrenjw » Fri Jul 20, 2012 6:00 pm
The main problem with openjdk(6) on raspbian is that the JIT compiler doesn't seem to work. With the icedtea-6-jre-cacao package installed, you are supposed to be able to enable the Cacao JIT with "java -cacao", but when I attempt this (on almost any of my code) the JVM crashes. I suspect that if the Cacao JIT could be fixed then openjdk would be quite usable. Also, openjdk7 is supposed to offer some performance improvements, but this isn't yet in the raspbian repos.
Posts: 3
Joined: Fri Jun 29, 2012 10:23 pm
by jan77 » Fri Jul 20, 2012 9:17 pm
Why don't you use JAMVM? This vm is often used in large scaled embedded projects. Memory efficient and fast at ARM platforms ;)

best regards,

jan
Posts: 9
Joined: Fri Jul 20, 2012 8:30 pm
by darrenjw » Fri Jul 20, 2012 9:43 pm
There doesn't appear to be any "jamvm" in the raspbian repos.
Posts: 3
Joined: Fri Jun 29, 2012 10:23 pm
by stevepdp » Fri Jul 20, 2012 9:51 pm
It looks like you may have to build it. See the JamVM site here.
User avatar
Posts: 285
Joined: Fri Oct 28, 2011 7:41 am
Location: Norfolk, UK
by mpthompson » Fri Jul 20, 2012 10:11 pm
Java is a place where Raspbian could really use help from people in the Raspberry Pi community who have an interest in Java. There are similar issues with Mono as well. Hopefully some very experienced Java developers can examine the Debian openjdk package and other Java related packages and tell us what changes need to be made to the build configurations to improve Java support. Plugwash and I try to do the best we can, but our experience with Java is very limited and our ability to really test and optimize the builds is limited as well.
User avatar
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA
by plugwash » Sat Jul 21, 2012 12:29 am
darrenjw wrote:There doesn't appear to be any "jamvm" in the raspbian repos.

That is because it came out contaiminated with armv7 code and I didn't have the time/inclination to figure out why.
Forum Moderator
Forum Moderator
Posts: 3131
Joined: Wed Dec 28, 2011 11:45 pm
by ksangeelee » Sat Jul 21, 2012 1:50 am
plugwash wrote:That is because it came out contaminated with armv7 code and I didn't have the time/inclination to figure out why.


How do you determine if a binary has armv7 code lurking in it?
Posts: 192
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK
by plugwash » Sat Jul 21, 2012 2:18 am
We have a script that calls readelf on every file in the package and checks for claims of armv7.

It's not a perfect system, there can be both false positives (e.g. code that does runtime CPU detection) and false negatives (e.g. JIT compilers) but it does keep the majority of v7 code out of our repo.

http://pastebin.com/BtSdvrXM

uncomment the "echo $filename" to determine which files are contaminated.
Forum Moderator
Forum Moderator
Posts: 3131
Joined: Wed Dec 28, 2011 11:45 pm
by mpthompson » Sat Jul 21, 2012 2:24 am
ksangeelee wrote:How do you determine if a binary has armv7 code lurking in it?


We have scripts that run 'readelf -A' on the resulting binaries from any build. This tool will indicate whether armv7 code is present in any of the code segments within the file. With Java things are a bit trickier in that the JIT generates executable code at runtime. Some JITs will dynamically detect the CPU environment and automatically adjust the instructions as needed to run on the CPU, but most will simply generate code for the CPU they were configured for. Finally, many JITs don't know how to generate armv6 instructions and will default to armv5 (a more popular platform) if they can't generate armv7 and thus loose the ability to use hard float instructions. Things are kind of a mess on ARM platforms because of so many different CPU variants with different capabilities.
User avatar
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA
by jan77 » Sat Jul 21, 2012 12:27 pm
Hmm, but isn't it compatible with fp emulation? Is the optimization for arm7 the target or to get java run at raspbian?
Posts: 9
Joined: Fri Jul 20, 2012 8:30 pm
by acobley » Sat Jul 21, 2012 1:23 pm
Well I'll have a go at compiling the JamVM and see if I can get it working.

Andy
Posts: 20
Joined: Fri Feb 10, 2012 9:54 am
by acobley » Sat Jul 21, 2012 2:29 pm
well the good news is it's quite easy to get JamVM running on the PI. I just downloaded the source, configure, make and make install.

The bad news is it doesn't look like it will run my application, trying to start cassandra gives:

Unrecognised command line option: -javaagent:/home/space/apache-cassandra-1.1.0/bin/../lib/jamm-0.2.5.jar

It looks like JamVM doesn't support Java Agents:

http://java.sun.com/developer/technical ... SE/jvm_ti/

Andy
Posts: 20
Joined: Fri Feb 10, 2012 9:54 am
by jan77 » Sat Jul 21, 2012 5:45 pm
hey Andy,

jamVM has some restrictions at low level platforms. Agents AND class proxies (used for various testing frameworks such as TestNG, JUnit etc.) won't work. But that's documented.
All the "standard" reflections work fine.

Hope that helps.
Posts: 9
Joined: Fri Jul 20, 2012 8:30 pm
by jan77 » Sat Jul 21, 2012 5:50 pm
Just as note: We have full blown OSGI's (knopflerfish 1.3 and 4) running at arm5 platforms with jamvm. Using thread pools, heavy reflections and of course some native stuff ;)
Posts: 9
Joined: Fri Jul 20, 2012 8:30 pm
by acobley » Sat Jul 21, 2012 5:53 pm
Thanks Jan77.

I'll investigate and see if jamm-0.2.5.jar is absolutely needed for Apache Cassandra.

Andy
Posts: 20
Joined: Fri Feb 10, 2012 9:54 am
by Augmental_UK » Sun Jul 22, 2012 2:09 am
+1 to this issue.

I am currently developing a library for full use of the GPIO header with Java. The full focus of my work on the Pi is with Java and with the best will in the world, the OpenJDK just doesn't measure up to the Oracle one in terms of performance. So, I was thrilled when their ARMv6 binary release worked flawlessly (and very fast) with Debian. The lack of compatibility with Raspbian is a big loss. I will be writing to Oracle to ask if they can produce a hard float version of the binary, but I am not hopeful. For one, they may well have good technical reason not to produce one. Secondly, its understandable that as a business they may not find a case to spend time on supporting a hobbyist community, if that's their only reason to produce a new release.

As I don't fully understand the fine points of compilation for soft/hard FP, I have to ask: since the Debian release runs the OracleJRE flawlessly, isn't it possible to make Raspbian run it as well? Does the kernel boot the CPU into a fundamentally different mode that it cannot accept the soft FP instructions? What's stopping it from running where Debian armel had no issues?
Posts: 4
Joined: Fri Jun 01, 2012 7:46 am
Location: Woking, Surrey
by mpthompson » Sun Jul 22, 2012 4:31 am
Augmental_UK wrote:As I don't fully understand the fine points of compilation for soft/hard FP, I have to ask: since the Debian release runs the OracleJRE flawlessly, isn't it possible to make Raspbian run it as well? Does the kernel boot the CPU into a fundamentally different mode that it cannot accept the soft FP instructions? What's stopping it from running where Debian armel had no issues?


The issue not with the CPU, but with all code on the system expecting to call each other using the hard float ABI (application binary interface) as opposed to the soft float ABI. It's a matter of conventions that all the software on the system agrees to. The reason for the different ABI's is best explained in this Debian document:

http://wiki.debian.org/ArmHardFloatPort

Up until the Raspberry Pi, there was no compelling reason for vendors such as Oracle to create a version of Java compiled for armv6+vfp with the hard float ABI. With asb mentioning above that the Foundation is in touch with JVM vendors, perhaps this will change.

Until then, the Debian Wheezy armel build is available to run Java on, but it won't benefit from hardware floating point instructions.
User avatar
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA