Categories
Eclipse IoT

Installing the Zulu open source Java Virtual Machine on Raspberry Pi

I’ve recently been playing with the early-access version of Zulu Embedded for ARM32. Zulu is an open-source and certified build of OpenJDK. It is a great alternative to the JRE from Oracle as it does not requires you to pay any licenses, and it is also a huge improvement over the OpenJDK build you can get off the Debian repositories, which is not really optimized for ARM (and that’s a euphemism! :smile:).

Before giving you more information on my experience running Eclipse IoT projects on Zulu in subsequent blog posts, here’s a quick tip for anyone interested in installing an alternate JVM on a Raspberry Pi (or pretty much any Linux-based environment, really), and switching between default JVMs easily.

Download the Zulu JVM

At the time of writing this blog post, Zulu for ARM32 is only available through an early access program. Once you’ve downloaded your Zulu archive, you need to unpack it somewhere on your system (in a zulu folder within our home directory, in this example). From the command-line, and while in the directory where you’ve downloaded Zulu:

mkdir ~/zulu
tar xvfpz ezre-1.8.0_60-8.9.0.6-cp1-eval-linux_aarch32.tar.gz -C ~/zulu

Add the Zulu JVM to the list of alternate VMs

The update-alternatives command-line utility allows to easily bind a given symbolic name to different commands. In our case, we want to update the symbolic link for /usr/bin/java

sudo update-alternatives --install /usr/bin/java java ~/zulu/ezre-1.8.0_60-8.9.0.7-cp3-eval-linux_aarch32/bin/java 100

Enable Zulu

sudo update-alternatives --config java

In the list of alternative Java version that’s proposed to you, select the one corresponding to Zulu by entering its ID and pressing .

And voila! Zulu is now your default Java Virtual Machine, you can check by executing the following command:

java -version
openjdk version "1.8.0_60-Zulu-Embedded"
OpenJDK Runtime Environment (build 1.8.0_60-Zulu-Embedded-EA3, profile compact1)
OpenJDK Minimal VM (build 25.60-b23, mixed mode, Evaluation)
Categories
Eclipse IoT

Running Eclipse Che on a Raspberry Pi

Eclipse Che is a very cool Eclipse technology that provides you with a browser-based IDE that can be extended with plug-ins for virtually any language, framework, or tool that you may want to use in your day-to-day development.

This means that, right from your browser, you can do Java development and have Maven automatically build your stuff, or do Javascript development and still be able to easily integrate with e.g grunt to build your website.

As you may have guessed, most of the magic of Che is in its server. While in many cases you will run the Che server on your own laptop or private server, it’s also pretty cool to run it on an embedded/IoT device such as Raspberry Pi so as not only you have an “IDE-in-a-box” setup, but you can also actually develop code targeting the Pi itself. And yes, that means blinking LEDs… and more ! 😉

Install Docker

Assuming you are running an up-to-date Jessie distribution, it should be fairly straightforward to install the armhf version of docker provided by the Hypriot team.

cd ~/Downloads
wget https://downloads.hypriot.com/docker-hypriot_1.10.3-1_armhf.deb
sudo dpkg -i docker-hypriot_1.10.3-1_armhf.deb
sudo usermod -aG docker pi

At this point, you want to quickly logout and login again, in order for the addition of the user pi to the docker group to be properly applied. Then, we can test that docker is indeed running:

docker ps

This should grant you with an empty list of running docker containers. How surprising!? But at least it means you have Docker setup taken care of!

FWIW, the Hypriot folks have a Debian repo for making things easier. I have had problems with it though so you may want to stay away from it until they fix it?

Downloading Che

wget https://install.codenvycorp.com/che/eclipse-che-latest.zip
unzip eclipse-che-latest.zip
cd eclipse-che*

Updating Che’s built-in stacks to be ARM-compatible

When Che creates your development environment, it instantiates a Docker container that has the tools you need. That is to say, if you are to do Node development, Che can provision a so-called “stack” that contains npm, grunt, etc. The stacks configured by default in Che are based on x86 Docker images, so you will need to replace them with armfh-compatible ones.

sed -i 's/codenvy\/ubuntu_jdk8/kartben\/armhf-che-jdk8/g' stacks/predefined-stacks.json
sed -i 's/codenvy\/node/kartben\/armhf-che-node/g' stacks/predefined-stacks.json

I’ve built an image for Java and Node development, which means you’ll be able to use the “Java”, “Node”, and “Blank” ready-to-go stacks. Should you want to have a look at the Dockerfiles for those, see here.

Note that you don’t have to use the built-in stacks, and you can also create your on-the-fly, using a custom recipe. There as well, the base Docker image you’re building from will need to be ARMHF. You may want to use images from hypriot or armv7 on DockerHub.

Update other default settings

The Raspberry Pi 3 is quad-core, which means you actually get some very decent performances out of it. However, it’s still an embedded sort of device, and SD cards are typically not fast either. It’s a good idea to increase the timeout Che uses to detect a workspace is properly provisioned.

sed -i 's/machine.ws_agent.max_start_time_ms=60000/machine.ws_agent.max_start_time_ms=240000/g' conf/che.properties

Launch Che!

You’re good to go! All that is left is to launch Che. As you will likely be accessing it from e.g your Desktop computer, you need to make sure to use the -r:<external-IP> command-line argument to make sure it works properly from “non-localhost”:

./bin/che.sh run -r:192.168.2.26

Note that depending on your setup, the JAVA_HOME environment variable may not be set, in which case Che will complain, and you will have to first set the said environment variable:

export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt

You can actually add this to your ~/.bashrc to make sure JAVA_HOME is always set.

That’s it! You can now use the Java and Node stacks, and start using your web browser to develop right on your Pi, with *all* the features you would expect from a “real” IDE. Enjoy, and stay tuned for a video tutorial soon.

Categories
Eclipse IoT

Upcoming Virtual IoT meetup sessions

We have some really great speakers lined up for the upcoming Virtual IoT meetup webinars. Please make sure to join the group and RSVP for the sessions you’d like to attend.
As always, we’re happy to hear your suggestions for future presentations, so feel free to drop me a note.

https://www.meetup.com/Virtual-IoT/events/229047493

https://www.meetup.com/Virtual-IoT/events/228706327

https://www.meetup.com/Virtual-IoT/events/228632951