logoDuke3DprogressionSmall.jpgWhen I bought my Mac a few months ago, there was some doubt about the support of apple for java. Java 6 was out for a while and Leopard was still shipped with java 5. There were a lot of blogs and a lot of reactions to the lag of support. For me it was not a real problem, java 5 was already a big step forward. Yes I was working for big corporations still doing IBM websphere 5.1. But since I have moved to JTeam (well oke, I am starting this week) I need java 6. I knew there was an opensource initiative to port java 6 to the mac. So I started googling for it. But I stumbled upon this site from apple: http://developer.apple.com/java/. There now is a developer release for java 6. I also started reading some other java related material for the mac. In this blog item I want to share some of the stuff I found. I do want to stress that most of the knowledge comes directly from the articles I have found on the mentioned website. I will try to give references if I can still find them.

read on for the tips.

Downloading java 6

Before you can download the software you need to become a member of the apple developer connection group. Go to the following url to download the java 6 developer preview 9.
http://developer.apple.com/java/download/
The downloaded package contains an installer for the java six library.

Learn about basic usage of java on Mac OSX Leopard

The best starting point for learning about java on Mac OSX Leopard is this link: http://developer.apple.com/java/javaleopard.html. The mac supports multiple version of java out of the box, after installing java 6 there are versions 3,4,5 and 6 available. You can find them in the following location:

/System/Library/Frameworks/JavaVM.framework/Versions
jettro:Versions jettro$ ls -al
total 56
drwxr-xr-x  14 root  wheel  476 Mar 29 12:20 .
drwxr-xr-x  11 root  wheel  374 Mar 18 19:41 ..
lrwxr-xr-x   1 root  wheel    5 Mar 18 19:41 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 Nov  4 17:54 1.4 -> 1.4.2
lrwxr-xr-x   1 root  wheel    3 Mar 18 19:41 1.4.1 -> 1.4
drwxr-xr-x   8 root  wheel  272 Aug  5  2007 1.4.2
lrwxr-xr-x   1 root  wheel    5 Nov  4 17:54 1.5 -> 1.5.0
drwxr-xr-x   9 root  wheel  306 Mar 29 11:15 1.5.0
lrwxr-xr-x   1 root  wheel    5 Mar 18 19:41 1.6 -> 1.6.0
drwxr-xr-x  10 root  wheel  340 Mar 29 11:14 1.6.0
drwxr-xr-x   8 root  wheel  272 Mar 18 19:41 A
lrwxr-xr-x   1 root  wheel    1 Mar 18 19:41 Current -> A
lrwxr-xr-x   1 root  wheel    3 Mar 29 11:16 CurrentJDK -> 1.6

As you can see, there are a lot of different folders and soft links here to be found. For me the softlink CurrentJDK is pointing to a different location than the default. I changed it to 1.6. If you have absolute no knowledge of unix, then I recommend you learn or you be very careful. I removed the old virtual link and created a new one. You have to be the super user to be able to do this.

sudo rm CurrentJDK
sudo ln -s 1.6 CurrentJDK

By going up one folder you can get a general idea about the usage of java. The most important is the Home soft link. This is the one you can use as a Java home when you need it.

/System/Library/Frameworks/JavaVM.framework
jettro:JavaVM.framework jettro$ ls -al
total 64
drwxr-xr-x  11 root  wheel   374 Mar 18 19:41 .
drwxr-xr-x  84 root  wheel  2856 Nov  4 17:54 ..
lrwxr-xr-x   1 root  wheel    27 Mar 18 19:41 Classes -> Versions/CurrentJDK/Classes
lrwxr-xr-x   1 root  wheel    24 Nov  4 17:54 CodeResources -> Versions/A/CodeResources
lrwxr-xr-x   1 root  wheel    28 Mar 18 19:41 Commands -> Versions/CurrentJDK/Commands
lrwxr-xr-x   1 root  wheel    24 Mar 18 19:41 Headers -> Versions/Current/Headers
lrwxr-xr-x   1 root  wheel    24 Mar 18 19:41 Home -> Versions/CurrentJDK/Home
lrwxr-xr-x   1 root  wheel    23 Mar 18 19:41 JavaVM -> Versions/Current/JavaVM
lrwxr-xr-x   1 root  wheel    29 Mar 18 19:41 Libraries -> Versions/CurrentJDK/Libraries
lrwxr-xr-x   1 root  wheel    26 Mar 18 19:41 Resources -> Versions/Current/Resources
drwxr-xr-x  14 root  wheel   476 Mar 29 12:20 Versions

Now we made IntelliJ make use of java 6, cool stuff or not. To control the default java versions for applications, applets and java webstart apple has provided us a utility application. Go to /Applications/Utilities/Java Preferences. Using the following screen you can adjust the version of java used by applets and programs.

Screendump_mac_java_settings.png

Now you can check the version of java by opening a command prompt and typing java -version.

jettro:~ jettro$ java -version
java version "1.6.0_04-dp"
Java(TM) SE Runtime Environment (build 1.6.0_04-dp-b06-110)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_04-b12-45-optimized, mixed mode)

So nice java 6 on the mac, bye bye old stuff.

Tagged on:     

10 thoughts on “Java on apple’s Mac OSX

  • Pingback: Iezzi.ch Blog » More OS X Leopard Tips & Tricks

  • May 18, 2008 at 7:52 pm
    Permalink

    As a reply to Mr. Buyer, check my other post on java on mac osx. To be honest, if you are not a programmer you can stick to what you have. There is pretty good java 5 support. If you really want to have java 6, there is an easy installer available on the mac download site. It is out of beta now and everybody can use it. By default java 6 is not put as the default since some applications do not support 64 bit. Applets are one of those. But apple will downgrade immediately. Still some projects/products might have problems. I for one had problems with cyberduck.

    In summary, do not upgrade if you have no special needs, use the installer for java 6 if you do want to stay up to date.

    Hope that helps

    Reply
  • May 17, 2008 at 10:30 pm
    Permalink

    Since you have already expressed the complications of executing some of these changes, I won’t even try. It would be nice if you could write something about Java for the end user. However, I am happy to see that someone knows SOMEthing about Java for Mac. Even if Apple does, I’ve found it’s hard to understand and not too easy to find on the apple web site as most of us aren’t in the developer mode.

    Reply
  • April 30, 2008 at 8:25 pm
    Permalink

    sudo ln -s CurrentJDK 1.6
    is wrong and potentially dangerous for unix-cluless. it should read opposite:
    sudo ln -s 1.6 CurrentJDK
    i make this mistake often too, and never remember the correct order.

    Reply
  • April 5, 2008 at 9:07 am
    Permalink

    Good to see you finally migrated to the real thing! I own my Mac for several years now. I admit I will not use your tips to use Java on it, but still good to read though ;-)

    Good luck with the new challenge at JTeam!

    Cheers
    Marcel

    Reply
  • April 3, 2008 at 9:29 am
    Permalink

    Unfortunately apple java 6 preview is only 64bit. So forget about eclipse :(

    Reply
  • April 2, 2008 at 10:02 am
    Permalink

    Cool post ! :)

    Got a macbook air yesterday! But have to go back today because the adapter did not work…. so I have been looking and touching it for the better part of the evening…. but could not turn it on unfortunatly… but who cares it looks really cool!!! hehe.

    Reply
  • March 31, 2008 at 6:58 am
    Permalink

    Hi,

    I am planning to buy a MAC in next 3-4 months. It will be my first mac. Your blog was simple great in explaining Java and Macs. Keep up your good work.

    Regards,
    Deepak

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>