Friday 23 April 2010

How to change the default JRE in Mac OS X (Leopard)

The problem was, my Eclipse installation was setup to use JRE 1.6 but when I checked using
mvn --version
it reported that it was using JRE 1.5. The solution's pretty simple in fact. The versions of Java JRE that are installed on your Mac are located in
/System/Library/Frameworks/JavaVM.framework/Versions
If you list the contents of the folder in terminal using
ls -al
then you'll see a symbolic link called "CurrentJDK" pointing to a symbolic link called "1.5" pointing to the latest version of 1.5 installed. Delete this link and recreate it pointing it to the symbolic link called "1.6" and you're done. The following code will achieve this.
 cd /System/Library/Frameworks/JavaVM.framwork/Versions/
sudo rm -r CurrentJDK
sudo ln -s 1.6 CurrentJDK
UPDATE Due to obvious confusion caused by my $ sign, I have reworked the code snippets to make them clearer

2 comments:

  1. you don;t need the $ sign. and i got this:
    rm: CurrentJDK: No such file or directory

    any help?

    ReplyDelete
  2. The $ sign is just to indicate the beginning of a new line in the terminal. You shouldn't type it in...

    if you ran the ls -al command in the folder listed above and didn't see the CurrentJDK then you should be good to run the last line (sudo ln -s 1.6 CurrentJDK) and create it anew.

    But I would double check that you were in the right directory when you ran the rm command.

    ReplyDelete

Please leave your feedback and comments. I love to discuss this stuff!