Mac Neophyte Tips: Changing the default Java version Date: 2008-06-23 09:57:54
OK, this one might also be widely known but it cost me a few minutes to figure it out, so here it goes: Software Update installs Java 1.6 on 64bit-capable Macs running Leopard. However, this doesn't mean they change the default runtime version that gets called when you click on a jar file or call code directly from the command line.
OS X's Java binaries live in a directory called "/System/Library/Frameworks/JavaVM.framework/Versions". On a 64bit Mac this should contain quite a handful of different runtimes:
This directory also houses two symlinks called "Current" and "CurrentJDK". As root in Terminal, remove those and replace them with symlinks to the 1.6 runtime:
There, all done! From now on "java -version" should return something like:
OS X's Java binaries live in a directory called "/System/Library/Frameworks/JavaVM.framework/Versions". On a 64bit Mac this should contain quite a handful of different runtimes:
lrwxr-xr-x 1 root wheel 5 Apr 30 12:25 1.3 -> 1.3.1
drwxr-xr-x 3 root wheel 102 Sep 29 2007 1.3.1
lrwxr-xr-x 1 root wheel 5 Jan 22 14:00 1.4 -> 1.4.2
lrwxr-xr-x 1 root wheel 3 Apr 30 12:25 1.4.1 -> 1.4
drwxr-xr-x 8 root wheel 272 Jan 22 14:00 1.4.2
lrwxr-xr-x 1 root wheel 5 Jan 22 14:00 1.5 -> 1.5.0
drwxr-xr-x 8 root wheel 272 Jan 22 14:00 1.5.0
lrwxr-xr-x 1 root wheel 5 Apr 30 12:25 1.6 -> 1.6.0
drwxr-xr-x 8 root wheel 272 Apr 30 12:25 1.6.0
This directory also houses two symlinks called "Current" and "CurrentJDK". As root in Terminal, remove those and replace them with symlinks to the 1.6 runtime:
rm Current*
ln -s 1.6.0/ Current
ln -s 1.6.0/ CurrentJDK
There, all done! From now on "java -version" should return something like:
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13-120)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_05-b13-52, mixed mode)
Comments
Jeff says
(2008-06-27 12:15:10)
I imagine they don't change the default version because of compatibility issues, right? But even so, it seems kind of dumb - most Java devs switched to 1.6
admin says
(2008-06-28 02:29:22)
I think they did it in order to NOT fragment the Leopard platform. Having to consider two Java versions for OS X (because older Macs can't upgrade) would be even more of a bummer for Java developers. I guess Apple just opted in favor of a uniform software base for their OS which kind of makes sense.
Of course, not having the upgrade option for 32bit Macs at all is kind of silly in the first place...
Of course, not having the upgrade option for 32bit Macs at all is kind of silly in the first place...
Name
Email
URL(optional)
Text
Page time:
0.362 seconds.