Understanding how Java works on Mac OS X

How does Java work on Mac OS X? Where is Java installed on Mac OS X? How is it possible to update Java on Mac OS X? If you are used to programming with Windows, then the first thing you would do when setting up your development environment is go and download the Java JDK from the sun download website. The great thing about developing Java applications on a Mac OS X is that your Mac arrives with Java already installed!

Yes, that’s right. There is no need to download or install Java on a Mac. Hurrah! You are probably thinking, well how do I know if I have the right version? How do I know if I have everything up to date? Well, for whatever version of Java that is installed on your machine, you can just do a normal mac software update and it will update your version of Java.

Now, in case you are wondering…

Where is Java located on my Mac OS X?

Open a TERMINAL window and enter the following.

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

$ ls
1.3 1.4 1.5 1.6 A CurrentJDK
1.3.1 1.4.2 1.5.0 1.6.0 Current

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

How can I upgrade from Java 1.5 to 1.6 or 1.7?

So you see that on my mac, I have java version 1.6. I also have many different versions of Java available on my mac! So, what version should you really have installed on your mac? If you want to upgrade, think twice before you do it. Maybe I just once had a bad experience changing around virtual links when I was still using my old leopard macbook pro. I tried the “hacker way” of upgrading from Java 1.5 to Java 1.6 in my terminal window and as a result, some of my applications including my Eclipse IDE did not work anymore. I couldn’t put it back for some reason, so I had to restore my system through time machine. I’ve seen lots of articles suggesting how to hack a java update through your mac terminal… but I have seen even more frantic forum users asking how to undo this hack.

If you just want your mac to use Java 1.6 because you are doing Java development in 1.6, then tell your IDE to use Java 1.6. Configure any system environment variables to use Java 1.6 if you like. That’s just my opinion… but you are free to proceed with updating your system through the terminal at your own risk ;)

Of course, if you have to, it’s always better to update Java this way:
System Preferences -> Applications -> Utilities -> Java Preferences

Do I need to set environment variables so my Eclipse IDE can locate Java?

No.

0 Comments

Post a Comment

(required):