Java, Equinox and EclipseRT on the Raspberry Pi
Earlier this week I ordered a Raspberry Pi and it arrived today.
For those of you who haven’t heard of the Raspberry Pi, it’s a low cost computer that includes HDMI (1080p) output, USB, Ethernet, an ARM processor (700Mhz) and 512Mb (or 256Mb) of RAM. The entire computer is the size of a credit card (or an Ontario Fishing License if you prefer), and can be purchased for as little as $25 ($35 for the 512Mb version). The board also includes 26 pins, allowing you to connect it to all sorts of crazy hardware — treating the little computer more like an embedded controller.
Backing up a decade, OSGi (the underlying modularity system used for Eclipse) was originally designed for embedded systems such as set-top boxes. The EclipseRT (Runtime Project) extended this work by bringing high quality runtime components to this programming model. EclipseRT includes components such as: a powerful webserver (Jetty), a provisioning platform (p2), persistence technology (EclipseLink), a rich widget toolkit for Ajax based applications (RAP), and more. The idea that you could create a full software stack based on Eclipse and deploy it on a stick has been on our minds for years, but a we lacked a low cost (and generally available) computing platform to deploy it too. With a Raspberry Pi in hand, I decided to revisit this vision.
To get started, you need an OS and a JVM. There is a Debian based distribution for the Raspberry Pi (Raspbian) and Oracle has a JVM for the ARM processor. Unfortunately the most common setup doesn’t work. The Oracle JVM does not support the hard-float ABI used by Raspbian. Lucky for us, there is a Raspbain image that supports soft-float ABI. Download this image and write it to an SD card (there are several good tutorials out there on how to do this). Once the image is on the card, you can start your Pi and install the JVM.
The application I used was a simple web based mail client that leverages RAP (for the widgets) Jetty (for the webserver), Apache Felix Gogo shell, and Equinox. The entire application was designed as an ‘Eclipse Product’ and built with Tycho. Because Raspberry Pi is not a supported architecture, we targeted Linux/x86 (knowing full well that no native libraries would work). Once the build was completed, the product was copied to the Pi.
The launchers that you get when you build a product are native, that is, binary executables for the particular platform. Because Raspberry Pi is not a support platform (yet), you cannot use the native launcher. Instead, you need to start your product by invoking Java and specifying the launcher jar.
With the runtime stack and mail application running on the Raspberry Pi, testing the setup is as simple as navigating to the Pi with a web browser.
While this is just an example, it does show that you can get a non-trivial OSGi application (46 bundles) running on a Raspberry Pi without much work. It also opens the door to a large collection of Eclipse based runtimes (including the modelling technologies, ECF and more) running on the Pi. Having the EclipseRT projects running on a Pi is a great addition to the other M2M (Machine-to-Machine) work that is happening at Eclipse.org.
For more information on what I’m doing with Eclipse, Equinox, p2 and the Raspberry Pi, feel free to follow me on Twitter (@irbull).