If you are developing in Java on Mac OS X you have probably already stumbled on a problem of choosing the correct Java version to run your programs.
The net is full of conflicting advise involving use of Java Preferences app in /Applications/Utilities vs. changing the symlinks to the CurrentJDK in /System/Library/Frameworks/JavaVM.framework/Versions
I have to say I've used both, but one last problem remained - the sudo user seem to get a different version of Java despite symlinks pointing to 1.6 or Java Preferences listing 1.6 at the top.
The problem can be solved by changing the "Current" symlink in the same directory normally pointing to (some mysterios) directory "A" to point to "1.6" too. However some applications don't like this at all - NeoOffice doesn't start for example.
I have been fighting with this problem several times already, but somehow would always end up with changing symlinks back and forth. Now thanks to Ambient Ideasthe answer is here.
So I turned to harness the wisdom of one of the really smart guys (that uses a Mac) I'm privileged to hang out with in Denver, Fred Jean. Fred said, "Try adding the 1.6 java explicitly to the front of your path rather than letting Java Preferences pane be the sole controller." I opened up ~/.bash_profile (alternatively you could edit ~/.bash_rc)and slammed in the following: