reddyvaribabu reddyvaribabu - 1 month ago 8
Java Question

Mac OS X 10.6.7 Java Path Current JDK confusing

I have trouble understanding (actual paths vs links) for multiple java versions on my Mac OSX. Normally in windows if I have multiple versions installed in my machine, I can just take the path of which ever version I want and use it. But in MAC OS X I undertand that there is something called links that is being pointed to CurrentJDK, and if I want to use a different version I will need to change the link to CurrentJdk right? But what is confusing for me is that as you can see below all my versions are pointing to the same CurrentJDK which means all versions point to current version? I was expecting only one of them would be pointing to CurrentJDK and I could just change it to which ever one I need which is not the case here. All I need to know is how to find the bin(Commands) folder path for each version, so that I can just use it to point to CurrentJDK? Also tell me how to change the link to CurrentJDK.

$ java -version

java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)

$ pwd

/System/Library/Frameworks/JavaVM.framework/Versions


$ ls -l

lrwxr-xr-x 1 root wheel 5 Mar 20 11:12 1.3 -> 1.3.1
drwxr-xr-x 3 root wheel 102 Dec 2 2009 1.3.1
lrwxr-xr-x 1 root wheel 10 Mar 20 11:12 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Mar 20 11:12 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Mar 20 11:12 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Mar 20 11:12 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Mar 20 11:12 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Mar 20 11:12 1.6.0 -> CurrentJDK
drwxr-xr-x 10 root wheel 340 Mar 20 11:13 A
lrwxr-xr-x 1 root wheel 1 Mar 20 11:12 Current -> A
lrwxr-xr-x 1 root wheel 59 Mar 20 11:12 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

Answer

Most possibly you only have one jdk installed, thus all the soft links points to the same jdk. If you however did have multiple jdks installed you would need to choose which one to use with the 'Java Preferences' app in your /Application/Utilities.

Soft links are by the way created with the 'ln -s' command from terminal.