Pages

Saturday, September 17, 2011

How to set Java 1.6 as default in Mac OX 10.5

Welcome to last year Apple. I've never seen a good explanation of why Apple has taken so long to release Java 1.6 for Mac OS X. I remember attending WWDC in 2000 when Steve Jobs announced that Java would be a first class citizen on Mac OS X. Things looked promising, but times have changed. I could understand waiting for the first patch, but this is the 5th patch for Java 1.6. We have been using Java 1.6 on hundreds of production systems in my group for over a year. I can't tell you how annoying it has been to run a VM on my Mac just so I can develop with Java 1.6. The delay for the release has been painful, I'm relived that my life will be improved now
Java 1.6 is not installed as the default, its just available:

After doing Software Update:

cmar$ java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)
when you type java at the command line, it invokes /usr/bin/java which is really a link to the Java Framework

Java Link

cmar$ ls -la /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Apr 30 08:41 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Switching you default

If you want to switch your default then you need to either modify the link /usr/java/bin
sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java /usr/bin/java
You might have to do "rm /usr/java/bin" first to remove the link before creating a new one.
Or you can just create an alias in your ~/.bash_login
alias java=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java

No comments:

Post a Comment