Sunday Nov 25, 2012

Prepping the Raspberry Pi for Java Excellence (part 1)

I've only recently been able to begin working seriously with my first Raspberry Pi, received months ago but hastily shelved in preparation for JavaOne. The Raspberry Pi and other diminutive computing platforms offer a glimpse of the potential of what is often referred to as the embedded space, the "Internet of Things" (IoT), or Machine to Machine (M2M) computing.

I have a few different configurations I want to use for multiple Raspberry Pis, but for each of them, I'll need to perform the following common steps to prepare them for their various tasks:

  • Load an OS onto an SD card
  • Get the Pi connected to the network
  • Load a JDK

I've been very happy to see good friend and JFXtras teammate Gerrit Grunwald document how to do these things on his blog (link to article here - check it out!), but I ran into some issues configuring wi-fi that caused me some needless grief. Not knowing if any of the pitfalls were caused by my slightly-older version of the Pi and not being able to find anything specific online to help me get past it, I kept chipping away at it until I broke through. The purpose of this post is to (hopefully) help someone else recognize the same issues if/when they encounter them and work past them quickly.

There is a great resource page here that covers several ways to get the OS on an SD card, but here is what I did (on a Mac):

  • Plug SD card into reader on/in Mac
  • Format it (FAT32)
  • Unmount it (diskutil unmountDisk diskn, where n is the disk number representing the SD card)
  • Transfer the disk image for Debian to the SD card (dd if=2012-08-08-wheezy-armel.img of=/dev/diskn bs=1m)
  • Eject the card from the Mac (diskutil eject diskn)

There are other ways, but this is fairly quick and painless, especially after you do it several times. Yes, I had to do that dance repeatedly (minus formatting) due to the wi-fi issues, as it kept killing the ability of the Pi to boot. You should be able to dramatically reduce the number of OS loads you do, though, if you do a few things with regard to your wi-fi.

Firstly, I strongly recommend you purchase the Edimax EW-7811Un wi-fi adapter. This adapter/chipset has been proven with the Raspberry Pi, it's tiny, and it's cheap. Avoid unnecessary aggravation and buy this one!

Secondly, visit this page for a script and instructions regarding how to configure your new wi-fi adapter with your Pi. Here is the rub, though: there is a missing step. At least there was for my combination of Pi version, OS version, and uncanny gift of timing and luck. :-)

Here is the sequence of steps I used to make the magic happen:

  • Plug your newly-minted SD card (with OS) into your Pi and connect a network cable (for internet connectivity)
  • Boot your Pi. On the first boot, do the following things:
    • Opt to have it use all space on the SD card (will require a reboot eventually)
    • Disable overscan
    • Set your timezone
    • Enable the ssh server
    • Update raspi-config
  • Reboot your Pi. This will reconfigure the SD to use all space (see above).
  • After you log in (UID: pi, password: raspberry), upgrade your OS. This was the missing step for me that put a merciful end to the repeated SD card re-imaging and made the wi-fi configuration trivial. To do so, just type sudo apt-get upgrade and give it several minutes to complete. Pour yourself a cup of coffee and congratulate yourself on the time you've just saved.  ;-)
  • With the OS upgrade finished, now you can follow Mr. Engman's directions (to the letter, please see link above), download his script, and let it work its magic. One aside: I plugged the little power-sipping Edimax directly into the Pi and it worked perfectly. No powered hub needed, at least in my configuration.

To recap, that OS upgrade (at least at this point, with this combination of OS/drivers/Pi version) is absolutely essential for a smooth experience. Miss that step, and you're in for hours of "fun". Save yourself!

I'll pick up next time with more of the Java side of the RasPi configuration, but as they say, you have to cross the moat to get into the castle. Hopefully, this will help you do just that. Until next time!

All the best,

Monday May 07, 2012

Looking Through the Telescope From the Big End: Four Small Java Developments that Pack a Punch!

There are a LOT of exciting developments in Java, almost on a daily basis. Most of them make a big splash, and for good reason! But sometimes, it's the little things...

There have been a lot of small developments in Java that are pretty exciting, too. I'll pick out four of my favorites - each at a different level and/or stage of development or detail - and explain why they're a big deal. Let's get started!

Home automation

I had the privilege of watching Vinicius and Yara Senger give a presentation at Jfokus (available below at on Java EE and home automation. The Sengers developed the jHome platform and run it on GlassFish, controlling Arduino-based appliances in their home, office, and boat. I won't give away all the spoilers, and it isn't Java end-to-end...but the Sengers are demonstrating a compelling, fully open source (hardware and software!) package for Java working in harmony with even the tiniest of devices.


FIRST, or "For Inspiration and Recognition of Science and Technology", was founded by world-renowned inventor Dean Kamen. In his words:

"Our mission is to inspire young people to be science and technology leaders, by engaging them in exciting mentor-based programs that build science, engineering and technology skills, that inspire innovation, and that foster well-rounded life capabilities including self-confidence, communication, and leadership."

FIRST's vehicle for doing this is robotics. Teams of various ages use available technology components and their brains to develop and program robots to compete in some pretty tricky challenges. This isn't Robot Wars (no Real Steel destructive matches here), but it's just as engaging - for the teams and spectators alike.

The 2012 FIRST International Championship was held in St. Louis, MO, USA, and teams representing several countries participated. I was able to attend for awhile - with an event like this, you just can't see it all! - and chanced upon a team in the pit area with a homemade sign saying "We use JAVA!". I was directed to the 15 year-old programmer who proudly informed me that they use NetBeans and Java to program their robot. We had a nice conversation, and I was left with the realization that Java's original "embedded" mission is still being realized in ways that we don't often think about.

Raspberry Pi

Simon Ritter recently posted about his work with the Raspberry Pi and JavaFX 2. I had seen others relate their victories getting OpenJDK onto the little Pi, a small-but-capable computer the size of a deck of cards...but Simon (and those who provided assists in whatever form) took the bar and threw it up onto the roof. It won't win any supercomputer awards (well, not alone anyway!), but the Raspberry Pi's small size and low price now make a host of formerly-unrealistic uses possible. Even before much optimization is done, JavaFX 2 is already running. If you've ever migrated existing software (of any kind) to a new platform, you know that that first "clean" run can be elusive. I can't wait to see how far we can take this...just as I can't wait for my pre-ordered Pi to hurry up and get here!

Harmonization of Java ME, SE

Henrik Stahl was on the Java Spotlight podcast recently (link below) presenting a clear vision for the harmonization of Java Micro Edition (ME) and Standard Edition (SE). The devil is in the details, of course, but here's the good news:

1) There is a plan
2) The plan makes sense
3) The plan is being worked...diligently!

Without getting into those details or the challenges surrounding them (API synchronization, Jigsaw, etc.), a modern, consistent set of APIs and a modular architecture should excite Java developers wherever they may fall along the spectrum.

The Bottom Line

It's an exciting time to work with Java at any level, and that includes in the crevices where small and/or embedded devices often lie hidden from view. If you haven't already been involved in "Java in the small", check it out. And if you have a favorite I've missed, drop me a line or comment below! If you like it, chances are the rest of us will, too.  :-)

All the best,

free counters


The Java Jungle addresses all things Java (of course!) and any other useful and interesting tools & platforms that help us GET IT DONE. "Artists ship," after all. :)

Your Java Jungle guide is Mark Heckler, a Software Architect/ Engineer and Oracle Developer Evangelist with development experience in numerous environments. Mark's current pursuits and passions all revolve around Java, the Cloud, & the IoT, and leave little time to blog or tweet - but somehow, he finds time to do both anyway.

Mark lives with his very understanding wife in the St. Louis, MO area.

Stay Connected


« June 2016