Building OpenJDK 8 on Mac OS X Yosemite

gblues edited this page Sep 6, 2018 · 12 revisions

Building OpenJDK 8 (update 40) on OS X 10.10 (Yosemite) was not a cakewalk, until recently the OpenJDK community released a series of patches for the same. These patches, combined with some mailing list replies, seem to be enough to build and enhance OpenJDK 8 successfully on Yosemite systems.

Downgrade your Xcode!

OpenJDK 8 doesn't work with the default llvm-clang compilers supplied with Mac OS X. So the first step is to download an older version of Xcode, which has the older gcc compilers available.

  • Login to with your Apple ID.
  • Download Xcode 4.6.3 (release date June 13, 2013).
  • Create a directory called Xcode4 inside /Applications/, and put inside it. This ensures that you could still use the default Xcode6x for other purposes.

Download the proper version of jdk8

OpenJDK 8 has different versions; you must download jdk8u to get the most up-to-date code, which includes buildfixes for Mac OSX.

  • Install mercurial (if not present, already). Check by writing hg --version on terminal.
  • Clone jdk8 from its mercurial repository: hg clone jdk8.
  • Get the complete sources: cd jdk8; bash This will take time depending on your internet speed (about 20 minutes on broadband).

Setup freetype

If './configure' fails with the error 'unable to find freetype', then you have to install it. It's easy to build and install freetype in Mac OS.

Set up environment variables

OpenJDK's configure script will require setting JAVA_HOME, MACOSX_DEPLOYMENT_TARGET, and SDKPATH variables:

# prevent "couldn't understand kern.osversion" and "The tested number of bits in the target (0) differs
# from the number of bits expected to be found in the target (64)" errors
# If you've put your Xcode4 in a different location, update this accordingly.
export SDKPATH=/Applications/Xcode4/
# Must be set such that $JAVA_HOME/javac -version reports 1.7.0
export JAVA_HOME=<path_to_jdk7>

Build jdk

Earlier, it was required to switch the default Xcode version (using sudo xcode-select -s / But now the path can be supplied using a flag while configuring. Thus, the final build steps are:

  • bash configure --with-xcode-path=/Applications/Xcode4/
  • make images

If successful, this step would take approximately 30 minutes (I suggest installing ccache for faster re-builds). If some error is thrown, try the patches mentioned in the next section.

Additional steps [deprecated]

The information below is old, and with the environment variables set properly they should be unnecessary. Most likely they were build system bugs that have since been fixed. They are left for archival purposes, just in case.

Based on my experience, different people may need to do one or more of the things below for a successful build. Please check whether the build works by doing things one-by-one, in the given order.

  • Apply the following patch to jdk8/hotspot/make/bsd/makefiles/saproc.make:
- SALIBS = -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
+ SALIBS = -isysroot /Applications/Xcode4/ -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation
  • Apply the following patch to jdk8/hotspot/make/bsd.makefiles/gcc.make:
  # The macro takes the version with no dots, ex: 1070
-  LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
+  LFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN)
  • Apply the following patch to jdk8/hotspot/make/bsd/makefiles/saproc.make:
ifneq ($(OS_VENDOR), Darwin)
+ else
+ # bring in minimum version argument or we'll fail on OSX 10.10

Run your new binaries

The newly-built binaries (javac, java, etc.) are found at:



External links:

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.