changing the default JVM on OSX Leopard

Posted by Dick on May 21, 2008

I’ve been using a bit of Java lately, and the OSX 1.6 JVM seemed pretty stable.

JRuby is the next thing on my geek list, and that runs best on Java 6.

Although the 1.6 JDK was installed in the last system update, it’s not the default:
 

hypnotoad:Desktop $ /usr/bin/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)
hypnotoad:Desktop $
hypnotoad:~ $ ls -l `which java`
lrwxr-xr-x  1 root  wheel  74 30 Apr 10:07 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
hypnotoad:~ $ cd /System/Library/Frameworks/JavaVM.framework/Versions/
hypnotoad:Versions $ ls -ld Current*
lrwxr-xr-x  1 root  wheel    1 30 Apr 10:08 Current -> A
lrwxr-xr-x  1 root  wheel    3 30 Apr 10:07 CurrentJDK -> 1.5

I know what you’re thinking. Don’t. Re-pointing those symlinks seems to work, but in fact it breaks all your GUI apps (the ‘A’ is for AWT)::

hypnotoad:Versions $ jconsole
2008-05-20 23:26:20.524 jconsole[680:10b] Apple AWT Startup Exception : ** -[NSCFArray insertObject:atIndex:]: attempt to insert nil
2008-05-20 23:26:20.525 jconsole[680:10b] Apple AWT Restarting Native Event Thread

Instead, you want to open /Applications/Utilities/Java/Java Preferences.App :

'Java Application Runtime Settings' determines the output of 'java -version'

hypnotoad:~ $ java -version
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)
hypnotoad:~ $

( ignore the text about ‘when an applet is executed in this browser’ - Intel Safari is 32-bit, and if you’re on PPC you don’t get JAVA 6 anyway ).

That Steve Jobs has a great sense of humour.

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Robert Rees Thu, 04 Sep 2008 19:46:16 GMT

    Thanks for the walkthrough. I was wondering how it was done without manually jigging the symlinks. It’s always easy when you know how!

Comments