2012.08.17 23:06 MDT
There's lots of information on the internet about getting a Java 1.5 JRE running in Snow Leopard, but if you update to OS X Mountain Lion you have to jump thru a few more hoops make it work. If you followed the previous instructions for Java 1.5 for OS X Lion then these instructions are almost identical with a small change to step 11 and 12, and they will continue to work beautifully for your OS X Lion installs. Here's what you need to do to make it all work in OS X Mountain Lion:
NOTE: To run Zend Studio 5.x in Lion or Mountain Lion, there's a better solution...
Go to Zend Studio 5.x for OS X Mountain Lion (Java SE 6).
Before we begin... if after reading this you hyperventilate or feel woozy, Brice Dutheil has created a very cool bash script that will perform all these steps for you. I haven't tried it personally but a quick sanity check of the code makes me think it would work as advertised. There's also some useful tricks in there, like mounting the dmg then extracting the pkg and payload data from the command line. All you isn't-there-just-something-I-could-run-that-would-just-do-it-all-for-me types should all be sending Brice your extra Amazon promo codes or something. However, those of you who like to get your figers dirty, read on...
Also, I had one report that in step 18 the /System/Library/Java/JavaVirtualMachines directory did not exist in their install, but /Library/Java/JavaVirtualMachines did. According to the report, using that direcory still resulted in a successful Java 1.5 VM. After installing the Apple supplied Java Runtime, choose the directory where 1.6.0.jdk is for step 18. Mine is in the System JVM directory. Thanks to Dakshinamurthy Karra.

$ sudo -s# cd /System/Library/Frameworks/JavaVM.framework/Versions# pwd
/System/Library/Frameworks/JavaVM.framework/Versions
# rm -i 1.5
remove 1.5? y
# rm -i 1.5.0
remove 1.5.0? y
# pwd
/System/Library/Frameworks/JavaVM.framework/Versions
# mv -v 1.5.0 1.5.0_30
1.5.0 -> 1.5.0_30# pwd
/System/Library/Frameworks/JavaVM.framework/Versions
# ditto -v --arch x86_64 1.5.0 1.5.0_30 && rm -rf 1.5.0
Copying 1.5.0_30 [x86_64]
# pwd
/System/Library/Frameworks/JavaVM.framework/Versions
# ln -sivh ./1.5.0_30 1.5
1.5 -> ./1.5.0_30
# ln -sivh ./1.5.0_30 1.5.0
1.5.0 -> ./1.5.0_30
# ls -Fld 1.5*
lrwxr-xr-x 1 root wheel 10 Jul 21 14:28 1.5@ -> ./1.5.0_30
lrwxr-xr-x 1 root wheel 10 Jul 21 14:29 1.5.0@ -> ./1.5.0_30
drwxr-xr-x 9 root wheel 306 Jul 21 14:26 1.5.0_30/# cd 1.5.0_30
# pwd
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
# vi ./Resources/Info.plist<key>JVMMaximumFrameworkVersion</key>
<string>*.*.*</string><key>JVMMaximumSystemVersion</key>
<string>10.*.*</string><plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>libjava.jnilib</string>
# pwd
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
# ln -siv ./Resources/Info.plist .
./Info.plist -> ./Resources/Info.plist
# ls -Fl Info.plist
lrwxr-xr-x 1 root wheel 22 Jul 21 14:01 Info.plist@ -> ./Resources/Info.plist# pwd
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
# mkdir -v ./MacOS
mkdir: created directory 'MacOS'
# cd ./MacOS# pwd
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30/MacOS
# ln -siv ../Libraries/libjava.jnilib .
./libjava.jnilib -> ../Libraries/libjava.jnilib
# ls -Fl libjava.jnilib
lrwxr-xr-x 1 root wheel 27 Jul 21 14:11 libjava.jnilib@ -> ../Libraries/libjava.jnilib# cd /System/Library/Java/JavaVirtualMachines
# pwd
/System/Library/Java/JavaVirtualMachines
# mkdir -v 1.5.0
mkdir: created directory '1.5.0'
# ls -Fl
drwxr-xr-x 2 root wheel 68 Jul 21 14:40 1.5.0/
drwxr-xr-x 3 root wheel 102 Jun 29 00:26 1.6.0.jdk/# cd 1.5.0
# pwd
/System/Library/Java/JavaVirtualMachines/1.5.0
# ln -sivh /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30 ./Contents
./Contents -> /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
# ls -Fl
lrwxr-xr-x 1 root wheel 61 Jul 21 16:40 Contents@ -> /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0_30
Questions or comments to blog [at] s [hyphen] seven [dot] net.
A few of you asked, so here you go...
(all donations will be use to buy coffee)