Monday Apr 30, 2012

JavaFX on the Raspberry Pi

Over the last few days I've been playing with the Raspberry Pi board (I was lucky enough to secure one of these as part of the work Oracle is doing to ensure that Java runs smoothly on it). 

Initial setup was pretty straightforward although I did need to check the current rating of the power supply I was using as the board needs 700mA, which is more than a normal USB port or hub supplies.  I used Win32DiskManager to copy the OS image to an SD card and then gparted to resize the partition to use the whole 8Gb on the card rather than just 2Gb.  Since I don't have a spare monitor I decided to do most things remotely over the network and set up sshd without any problem.

There is an OpenJDK build for ARM, but it doesn't have JIT support, so performance is not optimal.  Oracle provides a commercial implementation, which does have JIT support, so I downloaded and installed this which was painless. (The only thing to note here is I used the vfp version of the JDK).

Next, I figured I'd have a go at building JavaFX from source.  I grabbed a snapshot and set about seeing what needed to be done.  The first problem was that the reported platform didn't match anything in the build description (ARM v. x86).  Being a bit lazy I cheated.  Rather than configuring a whole new set of build rules I just overrode the architecture setting and forced it to i586.  Since the compiler is ARM, what's the worst that could happen?  This got me started, but then I bumped in to issues with some of the native media code compiling with SSE2 optimisations that don't exist on ARM.  A short learning curve later I switched to the ARM NEON equivalent, changed some definitions and got a bit further.  There were a few more issues around missing packages and left over .o files and then a stroke of real luck. 

Someone in Oracle contacted me to say that we already had an internal build of JavaFX for ARM which had been done for the Beagle Board and pointed me to where I could download it, which I duly did.  I copied over all the necessary bits as well as one of my own, simple JavaFX apps compiled into a jar.  After a few command line mis-starts I had JavaFX up and running on the Raspberry Pi!

Here's a quick video that shows the results:

At the moment this is as far as I've got.  I did try a more complex application, but ran into a problem with a missing library.  Something to track down later.

Getting the remote desktop working was a bit of a challenge, but not because of anything to do with the Raspberry Pi or Java.  Initially I thought I could use ssh -X and then project the X application (JavaFX) back to my Mac so I could do the screen capture.  Although this worked fine if the client machine was Linux every time I tried it on Mac OS X I got an access error for MIT-SHM.  It seemed the X environment was trying to use shared memory, which when the client and server are on different machines is not going to work.  I tried several ways to try and convince the system not to use the shared memory extensions, but it just wasn't happening.  In the end I gave up and decided that the path of least resistance was to use VNC and have the whole desktop visible on the Mac.

Stay tuned for more updates.

Sunday Apr 29, 2012

A Titanic event

This week I had the pleasure of traveling to Belfast for an IT event entitled, "The Titans are Coming". 

The Titans are coming

I've only ever been to Belfast once before and that was a brief visit to the University there.  This time around a local company, Brightwater Recruitment Specialists, had invited me to be part of a Java developer event they were organising.  It was an evening affair being held at the newly opened Titanic Exhibition Centre.  This is a most impressive building, as you can see from the photos.



I've had the pleasure of presenting in some interesting places in the past (on the Eiffel Tower, in front of a fish tank in the Barcelona Aquarium); presenting from a replica of the staircase in the Titanic definitely adds to that list.



Oracle and Java

In addition to my presentation on "What's Happening With Java" there was a very entertaining presentation from Adam Thilthorpe of the British Computer Society on professionalism in the IT industry.  This was followed by a great presentation from Dr Mark Little, CTO of JBoss, who gave his perspective on how the world of middleware and mobile devices was not just changing, but converging thanks to the effects of Moore's Law.

Judging by the discussions I had with people afterwards I think everyone really enjoyed the event and hopes that we can run some more like this.  Northern Ireland has a substantial number of companies involved in Java development (primarily in the area of financial services, but plenty in other areas such as well).  One of the comments I heard several times was the difficulty in recruiting experienced Java developers.  If you're looking for a job Belfast has a lot to offer.

All in all, a great event and we're already planning a similar event south of the border later in the year.  Watch this space and on twitter (@speakjava) for more details.

Tuesday Apr 17, 2012

The Blog Begins

My blog begins[Read More]

A blog covering aspects of Java SE, JavaFX and embedded Java that I find fun and interesting and want to share with other developers. As part of the Developer Outreach team at Oracle I write a lot of demo code and I use this blog to highlight useful tips and techniques I learn along the way.


April 2012 »