Java 5 Update for OSX
I took the new update for my java on my mac yesterday. At first i didnt notice any problems. But after a restart of CF I found it was using the new java and was not particularly happy. Some things worked fine but others were broken. As java 5 is an unsupported platform for ColdFusion MX 7 ( i think), I just wanted an easy way to downgrade my jre. After a quick search I found this article on Mac OS X Hints. This worked great for me.
Here is a way to make this happen. Open up TextEdit and paste in the code below.
#!/bin/sh
cd /System/Library/Frameworks/JavaVM.framework/Versions
CURJDK="`readlink CurrentJDK`"
echo Current JDK version: $CURJDK
if [ "$1" == "" ]; then
echo Installed versions:
ls
exit
fi
VERFOUND=`ls | grep $1 | head -n 1`
if [ "$VERFOUND" != "$1" ]; then
BASE="`basename $0`"
echo Error: Could not change JDK-- version $1 not installed!
echo Run $BASE without arguments to see a list of installed versions.
exit 127
fi
echo You must now enter your Mac OS X password to change the JDK.
sudo ln -fhsv $1 CurrentJDK
Save the file to your home directory as setJDK. Now open up Terminal(Application/Utilities/Terminal) and at the command line type:
chmod +x setJDK
Now press enter to run the command. This makes the file we created a script that can be executed. Now on the command line enter:
./setJDK
And then press enter to run the command. You will see output to the screen the list of java version you have installed. After picking the one you want ( I wanted 1.4.2 ) run this:
./setJDK 1.4.2
And press enter 1 last time to set your JDK version. Thats it. You can easily switch to another version or back to 5 if you like.
Good Luck

Interesting. I’ve had Java 5 on my Mac for a long time and wrote my own ‘switch’ script that does what your example does. However, I’ve never had problems with CFMX even tho’ I typically have Java 5 as my default JVM. JRun automatically selects the 1.4.2 JVM at startup (this is an old compatibility hack and it was why JRun always defaulted to 1.3 on Mac for a long time after 1.4.2 came out).
I can only assume Apple’s update has broken the code that selects the "compatible" JVM so JRun now gets the Java 5 JVM even when it asks for 1.4.2 – naughty Apple!
I also have Java 5 running on my Powerbook and everything is fine. The difference, I think, is that I’m using TomCat. I never really liked JRun so I’ve been downloading the installers from Macromedia for "Other" systems and doing a pure Java instal. I have Flex 2 and ColdFusion 7 running perfectly. I also found that, at least for my system (867Mhz), TomCat runs much faster with fewer resources used up.
I defintely remember seeing a release note on CF that said it will work with Java 5. It must be an Apple thing. I had to switch my JVM back.
http://cyberdust.wordpress.com/2006/04/18/warning-installing-the-417-apple-java-update-kills-coldfusion-server-again/
Steve, Macromedia has been *very clear* that Java 5 is *not* a supported platform for ColdFusion MX!
Hi,
I could not install coldfusion, becasue of this issue(I think).I can’t access the cf admin!
I tried:
Macintosh-3:~ johnbarrett$ ./setJDK 1.4.2
./setJDK: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf330: command not found
./setJDK: line 2: syntax error near unexpected token `}’
./setJDK: line 2: `{fonttblf0fswissfcharset77 Helvetica;}’
Is ther a way to get rid of these errors, and to start the JVM 1.42?
I think this is why I can’t install the Coldfusion & JRun.
Thanks so much,
John Barrett
Hi Simon,
Sorry about the last post, I guess when I saved the code, it made some weird text. I recopied it once it turned into a unix file(a black box),and ran everything you said, and it now runs the java 1.4.09 :)
This did not allow be to install cfmx, and so I think there are bigger issues going on.
Thanks so much, and I am sorry to write twice to you.
John
Thanks for documenting this. I noticed a lot of crashes following the Java update, but I couldn’t find anyone else having the problem!
I’m still running CMFX 6.1 on Jrun4 on an old powerbookG4, and found that if I add the following argument when launching Jrun4, then it works with Java 5.
Try setting the following system property (java.args=) in {JRun4_RootDir}/lib/jvm.config
-Djmx.invoke.getters=true
I haven’t looked to see what (if anything) will not work, but at least JRun (& CFMX) start up…
Dude, MANY thanks for this! TextEdit didn’t work too well for me but textwrangler did the trick.
Again, this worked perfectly so thanks a ton.
Dudes… I have not yet seemed to get CF up and running even after running the script given… I currntly have JRE 1.6 but used ./setJDK 1.4.2 in order to TRY to get CF to work…
The bloody thing still hangs when I try to load ./jrun -start deafult &
Meaning I want to run the default server in order to get cfusion to run, cf residing under the servers/cfusion path within {JRUN_HOME}/servers/
Does the 1.4.2 need to be set prior to installing?
I’m running 10.4.8 on PPC
thanks
I am having trouble getting this to work. I saved the file to my home directory, but when I use the terminal utility and type chmod +x setJDK it cannot find the file. Obviously, I put the file in the wrong place or I’m doing something wrong in the terminal utility (my first time to use). I put the file in my home folder named nancy. Isn’t that correct? What am I doing wrong?