“Don’t be too proud of this technological terror you’ve constructed. The ability to destroy a planet is insignificant next to the power of the Force.”
Because of annotation incompatibilities, Android cannot be built with Java 6.0 but requires the older Java SE 5.0. Kind of shameful, considering that J2SE 5.0 reached its end of service life (EOSL) on November 3, 2009, which is the date of the final publicly available update of version 5.0 (J2SE 5.0 Update 22). The Android document however states firmly:
“JDK 5.0, update 12 or higher. Java 6 is not supported, because of incompatibilities with @Override.”
Appropriately, Apple doesn’t include an end-of-life product in a current OS X release and therefore, Java 5.0 is absent on OS X 10.6 Snow Leopard. Still, if we want to build Android on a somewhat recent OS X version, we need Java 5. So here is how we can force this outdated Java version back into the current version of Mac OS X.
Step 1: Installing XCode
The XCode.mpkg is available on the SnowLeopard install DVD, in the Optional Installs folder. Installing, followed by an immediate Software Update, brings XCode to version 3.2.1., gcc to version 4.2.1 and Java to version 1.6.0_17. Anyway, we are currently more interested in Java 5 …
Step 2: Acquire Java 5.x for OS X
Java for Mac OS X 10.5 Update 6 can be downloaded from Apple’s support Web site here: http://support.apple.com/kb/DL971. This contains J2SE 5.0 to 1.5.0_22. The slightly newer Java for Mac OS X 10.5 Update 7, containing J2SE 5.0 to 1.5.0_24, is currently only available through the Apple’s developer site: http://developer.apple.com/technologies/xcode.html. Access is granted only to ADC member, but at its lowest level, membership is free.
Step 3: Deploying Java 5
No matter if you went with J2SE 1.5.0_22 or 1.5.0_24, deployment will works the same. First, we need to remove the Java 1.5 and 1.5.0 symbolic links, that currently still point to Java 6. With Finder, navigate to HD/System/Library/Frameworks/Java.VMframework/Versions, select 1.5 and 1.5.0 and drag both into the Trash; now empty the trash.
In a previous step we downloaded JavaForMacOSX10.5Update6.dmg or java_for_mac_os_x_10.5_update_7__9m3144.dmg and we now need to extract and deploy Java 1.5. from that diskimage, which can be most conveniently be done with a tool like Charlessoft’s Pacifist (available here: http://www.charlessoft.com).
Open the diskimage (dmg) with Pacifist and inside that diskimage navigate to: Contents of JavaFor MacOSX10.5Update7.pkg/System/Libarary/Frameworks/JavaVM.Frameworks/Versions Now right-click on 1.5.0 and select “Install to Default Location” and do the same for 1.5.
With Java 1.5 now deployed, we still need to fix the disk permissions, which can easily be done in Terminal, like so:
sudo chown -R root:wheel /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0 and
sudo chown -R root:wheel /System/Library/Frameworks/JavaVM.framework/Versions/1.5
Now with Java 5 forced back into OS X 10.6 we can open the Java Preferences application in /Applications/Utilities, which immediately recognizes Java 5 and allows us to give it precedence or even make it the only JavaVM available. In previous OS X 10.6 point releases, the command line tools java and javac didn’t honor settings entered through the Java Preferences app. However, this seems to be fixed in OS X 10.6.3.