21 April 2006 ~ 11 Comments

Java 5 Update for OSX

Uncategorized

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

Tags: , ,

11 Responses to “Java 5 Update for OSX”

  1. Sean Corfield 21 April 2006 at 2:29 pm Permalink

    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!

  2. Seth 21 April 2006 at 7:33 pm Permalink

    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.

  3. Steve House 22 April 2006 at 5:11 pm Permalink

    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/

  4. Sean Corfield 23 April 2006 at 10:38 am Permalink

    Steve, Macromedia has been *very clear* that Java 5 is *not* a supported platform for ColdFusion MX!

  5. John 30 April 2006 at 4:09 am Permalink

    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

  6. John 30 April 2006 at 5:14 am Permalink

    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

  7. Brian Panulla 1 May 2006 at 6:39 am Permalink

    Thanks for documenting this. I noticed a lot of crashes following the Java update, but I couldn’t find anyone else having the problem!

  8. Stephen 5 May 2006 at 1:43 pm Permalink

    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…

  9. jyoseph 23 September 2006 at 12:36 pm Permalink

    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.

  10. Tiberius Meszaros 14 January 2007 at 3:14 am Permalink

    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

  11. Nancy 23 May 2007 at 2:04 pm Permalink

    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?


PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIEhpISBNeSBuYW1lIGlzIFNpbWVvbiBCYXRlbWFuIGFuZCBJIGFtIGEgd2ViIGFwcGxpY2F0aW9uIGRldmVsb3BlciBzcGVjaWFsaXppbmcgaW4gdGhlIEFkb2JlIEZsYXNoIFBsYXRmb3JtLiAgSSBhbSBhbiBBZG9iZSBDb21tdW5pdHkgUHJvZmVzc2lvbmFsIGFuZCBhbiBBZG9iZSBDZXJ0aWZpZWQgVHJhaW5lciBmb3IgRmxleCBhbmQgQUlSLiAgSSBhbSBhbHNvIHRoZSBQcmluY2lwbGUgSW5zdGlnYXRvciBmb3IgUE5XIFJhaW4gTExDIGEgUklBIGNvbnN1bHRpbmcgYW5kIG1lbnRvcmluZyBjb21wYW55LjwvbGk+PGxpPjxzdHJvbmc+d29vX2Fkc19yb3RhdGU8L3N0cm9uZz4gLSB0cnVlPC9saT48bGk+PHN0cm9uZz53b29fYWRfaW1hZ2VfMTwvc3Ryb25nPiAtIGh0dHA6Ly93d3cud29vdGhlbWVzLmNvbS9hZHMvd29vdGhl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