good robots do what they're told

Java source on Mac

Mostly as a reminder to myself, getting the Java source on your Mac involves the following.

  1. Go to the Apple Developer Connection downloads page.
  2. For Lion and above, search for Java for Mac OS X (2006-2012) Developer Package. The developer bundle includes the source whereas the regular software update version does not.
  3. For older versions (pre-Lion), search for Java for Mac OS X 10.x Developer Package where 10.x matches your version of OS X.
  4. Download and install.
  5. Open a window
  6. cd $JAVA_HOME (aka /System/Library/Frameworks/JavaVM.framework/Home)
  7. Setup a symlink to the source archive with sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home/src.jar
  8. And for the JavaDoc, sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/docs.jar
  9. Now point your IDE of choice to the new source folder symlink.


Any update to Java will set things up to point to Maven 3, so if you use Maven 2, it’ll break things with

java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

Reset things by;

  1. cd /usr/share
  2. sudo mv maven (a symlink which should incorrectly be pointing to java/maven-3.0.3)
  3. sudo ln -s /maven2/install/folder maven
  4. run mvn -version to check its back up.
  5. Have a cup of tea.

This is most likely caused because you have an M2_HOME set, if you’d prefer to use Maven 3, remove the Maven 2 path setting with export M2_HOME=.


Prior to OS X 10.7, you could run the Java Preferences app /Applications/Utilities/Java to show your newly installed Java version. For example, after the install step above, you could check that “Java SE x (System)” was in the list.

However, Apple have recently removed this app as they move away from in house support of Java.