Thursday, August 4, 2011

Broken Mac OS 10.6 (and 10.7 and 10.8 and...) Java

Apple has a pretty lousy history with Java support, but this still surprised me. If you are having trouble getting programs to compile with older Java versions (e.g. for backward compatibility), you might want to take a look in this directory: /System/Library/Frameworks/JavaVM.framework/Versions

Here's what I found on my OS 10.6 system:

lrwxrwxr-x   1 root  wheel    5 Jun 29 13:37 1.3 -> 1.3.1
drwxr-xr-x   3 root  wheel  102 Feb 11  2010 1.3.1
lrwxrwxr-x   1 root  wheel   10 Jun 29 13:37 1.4 -> CurrentJDK
lrwxrwxr-x   1 root  wheel   10 Jun 29 13:37 1.4.2 -> CurrentJDK
lrwxrwxr-x   1 root  wheel   10 Jun 29 13:37 1.5 -> CurrentJDK
lrwxrwxr-x   1 root  wheel   10 Jun 29 13:37 1.5.0 -> CurrentJDK
lrwxrwxr-x   1 root  wheel   10 Jun 29 13:37 1.6 -> CurrentJDK
lrwxrwxr-x   1 root  wheel   10 Jun 29 13:37 1.6.0 -> CurrentJDK
lrwxrwxr-x   1 root  wheel   59 Jun 29 13:37 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

I kept trying to get Eclipse to compile with 1.5 and kept getting incompatible binaries. Thanks Apple! YMMV, but I found this post a good guide to getting a real Java 1.5 installation.

3 comments:

  1. Here's what I had. I still have no idea why this is so completely and utterly broken. It is outrageously complex and there is NO documentation I can find that explains anything about it.

    bash-3.2$ ls -l
    total 72
    lrwxr-xr-x 1 root wheel 5 Dec 18 07:44 1.3 -> 1.3.1
    drwxr-xr-x 3 root wheel 102 Feb 11 2010 1.3.1
    lrwxr-xr-x 1 root wheel 10 Dec 18 07:44 1.4 -> CurrentJDK
    lrwxr-xr-x 1 root wheel 10 Dec 18 07:44 1.4.2 -> CurrentJDK
    lrwxr-xr-x 1 root wheel 10 Dec 18 07:44 1.5 -> CurrentJDK
    lrwxr-xr-x 1 root wheel 10 Dec 18 07:44 1.5.0 -> CurrentJDK
    lrwxr-xr-x 1 root wheel 10 Dec 18 07:44 1.6 -> CurrentJDK
    lrwxr-xr-x 1 root wheel 10 Dec 18 07:44 1.6.0 -> CurrentJDK
    drwxr-xr-x 10 root wheel 340 Dec 18 07:47 A
    lrwxr-xr-x 1 root wheel 1 Dec 18 07:44 Current -> A
    lrwxr-xr-x 1 root wheel 59 Dec 18 07:44 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

    ReplyDelete
    Replies
    1. @Anon, just to follow up, I wouldn't say it's outrageously complex. They just have only the 1.6 JDK and point all the others to it so that your machine thinks you have things that it doesn't have. I agree it is completely and utterly broken though, as this setup is pretty much guaranteed to break older software in surprising and subtle ways.

      Delete
  2. Nice, just confirmed that this is still Apple's setup on OS 10.8 Mountain Lion. Generally the Mac is a good dev machine, but be ready for these subtle FUs from Cupertino. Migrating slowly but surely to Linux...

    ReplyDelete