odvratno.zgodan
Posts: 1
Joined: Wed Dec 28, 2011 1:56 pm

Re: Java VM

Wed Dec 28, 2011 2:06 pm

Hi,

I'm not sure whether this question has been already asked, but will it be possible to run a Java VM on any of the distros used with the R.Pi?

techy
Posts: 2
Joined: Sat Dec 24, 2011 4:56 pm

Re: Java VM

Wed Dec 28, 2011 3:24 pm

What I understand is "NO"

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26104
Joined: Sat Jul 30, 2011 7:41 pm

Re: Java VM

Wed Dec 28, 2011 3:35 pm

odvratno.zgodan said:


Hi,

I'm not sure whether this question has been already asked, but will it be possible to run a Java VM on any of the distros used with the R.Pi?


Yes, but with the limited memory available the performance may not be great. Although I didnt get one working, I think OpenJDK ?) has been seen going on an alpha board.

The forums have a lot about Java - do a  search.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

asb
Forum Moderator
Forum Moderator
Posts: 853
Joined: Fri Sep 16, 2011 7:16 pm
Contact: Website

Re: Java VM

Thu Dec 29, 2011 11:12 am

JamesH said:


Yes, but with the limited memory available the performance may not be great. Although I didnt get one working, I think OpenJDK ?) has been seen going on an alpha board.

The forums have a lot about Java - do a  search.


Yep, that was me. I ran GeoGebra and Jedit amongst others. Performance was fairly sluggish, but much of that may be the lack of X acceleration.

CombatWombat42
Posts: 3
Joined: Thu Dec 29, 2011 4:49 am

Re: Java VM

Fri Dec 30, 2011 2:31 am

JamesH said:


odvratno.zgodan said:


Hi,

I'm not sure whether this question has been already asked, but will it be possible to run a Java VM on any of the distros used with the R.Pi?


Yes, but with the limited memory available the performance may not be great. Although I didnt get one working, I think OpenJDK ?) has been seen going on an alpha board.

The forums have a lot about Java - do a  search.


128MB of memory is not very limited. Java will run fine.

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

Re: Java VM

Wed Jan 04, 2012 9:14 pm

To get a feel for the performance of Java on slow-ish ARM machines, I've been playing with OpenJDK 6 on an ARM QEMU emulator today. My emulator claims to have a performance of around 250 BogoMIPS - about half a Pi? However, I imagine disk access is probably somewhat faster on my machine than reading from an SD card.

Running simple command-line apps, my first impression of performance hasn't been too shabby. I haven't tried any Swing apps yet.

However, the javac compiler was initially painfully slow in my emulator, which wouldn't give a good impression -- about 25 seconds just to compile HelloWorld.java. This mostly seems to be a fixed startup cost of the compiler; hprof (the in-built JVM profiler) shows unpacking JAR files and loading classes is a major factor.

If it helps anyone trying the same...

1. Try running javac with "-J-cacao" command line option, to use the cacao VM instead of the default server VM. For me this reduced the compile time for HelloWorld.java down to about 15 seconds from 25 seconds. Still not great.

2. I've created a simple single-class javac daemon that calls javax.tools.JavaCompiler. This eliminates the start-up cost of the compiler by getting it to hang around in the background. After initial startup, daemon can compile HelloWorld in less than a second. This PoC was about an hour's work, and can definitely do with some more polish.

If Java compiler performance leaves something to be desired once anyone gets around to trying to develop with Java on a real Pi, I'm happy to spend some time tidying up my javac daemon to get it into a state where I'm not too embarrassed for it to be used by others. Let me know if you're interested.

Chris

SeanD
Posts: 121
Joined: Wed Sep 21, 2011 12:25 am
Contact: Website

Re: Java VM

Wed Jan 04, 2012 10:55 pm

Option (2) sounds very similar to things we have built for production build systems in the past.  The trade off on the Pi would be that the daemon will be contending with the execution of the compiled code.  Probably great for learning, but challenging for larger solutions.

When the demand comes (and it will) I will lend a hand in getting this robust with you.

alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
Contact: Website

Re: Java VM

Wed Jan 04, 2012 11:07 pm

Option 2 sounds good for geeks. However for students?...  Maybe we just have to set the expectation that it's slow
--
Alec Clews <[email protected]>
http://about.me/alecthegeek

fdown
Posts: 2
Joined: Wed Jan 04, 2012 11:19 pm
Contact: Website

Re: Java VM

Wed Jan 04, 2012 11:35 pm

I would like to get Tomcat running on the pi, so I need Java, I would compile my Java else where and download the class files into the system.

This idea of compiling on one machine and running on another might be a nice teaching example, it shows how embedded software is made, and also the write  one place run everywhere feature of Java.

befunged
Posts: 1
Joined: Wed Jan 04, 2012 11:39 pm

Re: Java VM

Wed Jan 04, 2012 11:45 pm

It may be possible to run the eclipse compiler for java (ecj) - it's significantly faster than javac

http://www.archlinux.org/packa.....lipse-ecj/

Compiling on one machine (e.g. windows) and running on another (e.g linux) is standard practice in the java world and won't cause any problems

SeanD
Posts: 121
Joined: Wed Sep 21, 2011 12:25 am
Contact: Website

Re: Java VM

Thu Jan 05, 2012 2:37 am

In at least one implementation it would be good if we could keep everything on one machine and fairly performant.  Whilst I know a lot of people are looking at the RPi for specific applications we need to have a learning platform where kids (or whoever) can get this stuff to work fairly painlessly.

alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
Contact: Website

Re: Java VM

Thu Jan 05, 2012 8:29 am

SeanD said:


In at least one implementation it would be good if we could keep everything on one machine and fairly performant.  Whilst I know a lot of people are looking at the RPi for specific applications we need to have a learning platform where kids (or whoever) can get this stuff to work fairly painlessly.


+1

It would also be useful if the Greefoot and BlueJ team got their Java teaching tools working on the RasPi -- they already have it on their todo list.
--
Alec Clews <[email protected]>
http://about.me/alecthegeek

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

Re: Java VM

Thu Jan 05, 2012 10:55 am

I was actually thinking of Option 2 for kids developing on the Pi, rather than geeks who are likely to have their own beefy PCs running their favourite heavyweight IDE for compiling. Something suitable for working with Robocode, for example.

I expect it can be implemented as a drop-in replacement for javac (javacd?) with the same command-line options so there would be nothing much to learn other than how to install.

(Forum has post and cancel buttons too close together for use on a phone screen. Lost my post once ... grrrr)

sunnychan
Posts: 4
Joined: Wed Jan 11, 2012 6:15 am
Contact: Website

Re: Java VM

Wed Jan 11, 2012 6:27 am

One of the reason for OpenJDK to be quite slow is that it doesn't have a good JIT compiler. Oracle does make an Server Hotspot JIT compiler which is fairly performant, but it is only free for development (but not free for deployment).

http://www.oracle.com/technetw.....index.html

The memory requirement for these are not that great (32MB). I tried the build on my Synology diskstation and it seems pretty fast - I can run jetty and things on it.

Give that a try and see how it perform on Raspberry Pi, and then we shall lobby Oracle to let people use JSE embedded on Raspberry Pi for free (or get them to opensource the Hotspot JIT!)

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

Re: Java VM

Wed Jan 11, 2012 5:01 pm

Thanks. I just tried this, but as far as I can tell the server JIT only runs on ARM v7.

Error occurred during initialization of VM

Server VM is only supported on ARMv7+ VFP

This seems to document the fact:

http://www.oracle.com/technetw.....ml#sysreqs

Does anyone know the status of the Shark JIT for OpenJDK on ARM/Linux? I have found several old web pages (2010) saying it's not quite stable yet, but nothing recent. The Debian OpenJDK 1.6.0 runtime I installed mentions the "-shark" command line option with "java -help", but it isn't installed.

sunnychan
Posts: 4
Joined: Wed Jan 11, 2012 6:15 am
Contact: Website

Re: Java VM

Thu Jan 12, 2012 8:04 pm

Have you tried the ARMv5 build of the Oracle's Embedded VM? Even with the client VM

I think that would be more stable and faster then Shark.

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

Re: Java VM

Fri Jan 13, 2012 9:01 pm

Thanks, you're right -- the Oracle Embedded Client VM does generally seem substantially faster than the others I tried.

Running my own benchmark of XML manipulation (create a DOM, serialize, parse, repeat for a couple of mins after a warm-up -- lots of object allocation and string manipulation) showed the Oracle client VM to be about 3-4x faster than cacao, and about 7x faster than the interpreted OpenJDK server VM. Oddly shark was slowest of all in my test.

This is on an ARM emulator running on x64, quite possibly not representative of a real RP, but I imagine the relative performance might be similar.

Shame really, I don't particularly want to advise people to use the non-free Oracle software in case they fall foul of licensing.

PS. Sunny, I just realised that it's you. Small world!

alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
Contact: Website

Re: Java VM

Fri Jan 13, 2012 9:22 pm

Anyone have contacts at Oracle? Maybe they will cut RasPi a license.

I'm happy to manage that process given how busy everyone is. However I'd want official blessing from the foundation before I approached Oracle
--
Alec Clews <[email protected]>
http://about.me/alecthegeek

pgrassia
Posts: 13
Joined: Wed Aug 31, 2011 2:51 pm

Re: Java VM

Fri Jan 13, 2012 10:06 pm

more details about running a tomcat server on an ARM tiny box (here the sheeva plug, arm v5, higher cpu more ram, not sure how it compares with the raspi) at

http://www.earth.org.uk/note-o.....setup.html

alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
Contact: Website

Re: Java VM

Fri Jan 13, 2012 10:34 pm

If Oracle Java Embedded SE is the best technology then I this link is relevant to the licensing issue.

http://www.oracle.com/technetw.....html#faq10

As I interpret this, as RasPi is an educational and general purpose development platform then it should attract the free (as in beer) license. The license will only become an issue if someone makes RasPo part of a larger product (embedded), which is their problem and can be documented in the release notes for the OS image (or package)

We would be wise however to seek confirmation from Oracle and make sure that they are happy to have the SDK shipped in a Linux image.
--
Alec Clews <[email protected]>
http://about.me/alecthegeek

sunnychan
Posts: 4
Joined: Wed Jan 11, 2012 6:15 am
Contact: Website

Re: Java VM

Sat Jan 14, 2012 8:05 am

I know a couple of people from Oracle's Java team. Alec can you message me offline and I can give those contacts to you.

zubzub
Posts: 2
Joined: Tue Jan 17, 2012 4:45 pm
Contact: Website

Re: Java VM

Thu Jan 26, 2012 10:38 am

I currently work for a company that does embedded java development. We also have our own jvm for embedded devices so we have some expertise in that field.

As a hobby project I'm going to find out what the best linux+jvm combination is and what the possibilities are (java 1.4 <> java5+, JIT, Jazelle <> ThumbEE, ...).

davidgoodenough
Posts: 74
Joined: Wed Sep 21, 2011 11:55 am

Re: Java VM

Thu Jan 26, 2012 11:15 am

It really would be wonderful if ARM could release Jazelle to the Open Source world, and then we could have Java VMs that motor on machines such as the Pi.

It seems so short sighted to have the wonderful facility and for it not to be used.  If anyone has access to management in ARM it would be good to give them a push.  Does anyone know, even anecdotally why they do not release it?

alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
Contact: Website

Re: Java VM

Thu Jan 26, 2012 7:24 pm

I've contacted Liz about Oracle, however I'm guessing she is kinda busy at the moment.
--
Alec Clews <[email protected]>
http://about.me/alecthegeek

aballen
Posts: 7
Joined: Tue Dec 20, 2011 3:09 pm

Re: Java VM

Thu Jan 26, 2012 7:27 pm

I think this is a great idea.  I would love to get Jini running on the raspberry pi.

Return to “General discussion”