Topics and trends related to the Java ecosystem with occasional random rants.

  • May 30, 2018

Build JDK 10 for your Raspberry Pi Right on your Device

James Connors
Principal Solutions Consultant

Starting with the release of JDK 9, Oracle's list of supported hardware architecture / operating system platforms for its Java SE implementation has been trimmed.  No longer are 32-bit versions being provided, nor are binaries for the Arm architecture, including those for the wildly popular Raspberry Pi.  However, work supporting the 32-bit armhf architecture is incorporated in the OpenJDK source including that for OpenJDK 10.  So for all the Raspberry Pi / Java aficionados out there, you effectively have two options if you want the latest Java release for your device:

  1. Wait for someone to build and provide an installable package for your desired update.
  2. Build it yourself.

We'll discuss option (2) today, and with the resources available on the latest models of the Raspberry Pi, show that it is feasible to build Java from source right on your device.

For the impatient (which definitely includes this author), here are the instructions to get you going.

The aforementioned howto is divided into 7 relatively straightforward steps.  Here are some of the more important considerations:

  • Do not use any Raspberry Pi hardware with less than 1GB RAM.  OpenJDK build machines have a bare minimum build environment, and the less capable Raspberry Pi devices will be inadequate.  The example build system here uses the Raspberry Pi 3+.  As of this article's posting, it represents the latest and most capable Raspberry Pi to date.
  • You'll need to configure at least 1GB additional swap space.  This is explained in the instructions.
  • You should have at least 10GB free disk space to accommodate the source code and resulting built binaries.
  • As many Raspberry Pi versions are equipped with multiple cores, don't be tempted to take advantage of those cores by issuing the make command with a JOBS number greater than 1.  Increasing the JOBS count requires more RAM, a precious resource the Raspberry Pi doesn't have enough of, which will ultimately cause the build to fail.

How long does it take to build?

Depending upon the quality of the SD card you use, your mileage will vary.  In this instance, A 32GB SanDisk Extreme U3 SD card was used.  The total time reuired to issue the make command was approximately 216 minutes, or a little more than 3 ½ hours.

And what about JavaFX?

As of Java 10's GA release, JavaFX is no longer part of the JDK distribution.  To add this platform, you can either download a build of JavaFX that has been completed by the community, or build it yourself by following these instructions.  Unfortunately at this time you cannot build OpenJFX natively on the Raspberry Pi device.  You'll need to cross-compile the source from a supported development platfom, like for example, a Linux x64 system.


Since the creation of this article's original build instructions, JDK 10.0.1 has been released.  You can build this version of Java in a very similar manner, but a few small changes need to be made, including locating and pulling down the appropriate JDK 10.0.1 update source code.  The instructions contain a Postscript section which should aid in this endeavor.


Join the discussion

Comments ( 1 )
  • Elroy Saturday, July 28, 2018
    It doesn't work on the RPi B+.
    When I try to cross compile it from an Inter 32 bit platform, then I can't get the tests running.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.