Twitter GitHub Facebook Instagram

Daniel Irvine on building software

Upgrading to Java 8 with Buildr

9 September 2014

Upgrading a Buildr-managed project to Java 8 requires that you correctly set JAVA_HOME.

On Mac OS, the executable /usr/libexec/java_home will list installed JDKs:

~/Work/jTtt (master) $ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    1.8.0_20, x86_64:	Java SE 8	/.../JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
    1.6.0_65-b14-462, x86_64:	Java SE 6	/.../JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-462, i386:	Java SE 6	/.../JavaVirtualMachines/1.6.0.jdk/Contents/Home

You can use this to set JAVA_HOME once and once only:

export JAVA_HOME=$(/usr/libexec/java_home)

Once done, Buildr will automatically pick the latest SDK to build your Java profile. This should future-proof you from later Java upgrades.

You can specify which JDK is used using the following project option:

compile.options.source = '1.8' = '1.8'

About the author

Daniel Irvine is a software craftsman at 8th Light, based in London. These days he prefers to code in Clojure and Ruby, despite having been a C++ and C# developer for the majority of his career.

For a longer bio please see To contact Daniel, send a tweet to @d_ir or use the comments section below.

Twitter GitHub Facebook Instagram