This website explains how to compile and run Java 2 SE 5.0 (Java 1.5) programs on the Mac OS X. It is intended as an introductory guide for first- and second-semester Java students, but can be used by anyone. I've also recently added an additional section with information on how to make your Java programs more Mac-friendly.

Installation Instructions For Tiger (10.4)

If you are using Tiger, make sure you have upgraded to the most recent release of the operating system (10.4.7 at present). You can check what version of the OS you're running by going to "About This Mac" in the drop-down Apple menu. If your version is an older version, please run "Software Update" (also from the drop-down Apple menu). IMPORTANT: Mac OS X now automatically comes bundled with the latest version of Java. See the Using Java on your Mac section to continue from here.

If you ever want to check what version of Java you are running:
  1. Open up the Terminal by going to Applications > Utilities > Terminal.app.
  2. Type: ls -l /System/Library/Frameworks/JavaVM.framework/Versions/
  3. You should see "Current JDK" listed, with an arrow pointing to some version numbers. If you have the most current version installed, it should say "Current JDK -> 1.5.0". That number is the current version of Java you are using.

Instructions For Panther (10.3)

If you are using Panther, you cannot install Java 1.5. The latest version of Java that Panther supports is 1.4. You can still write basic programs with Java 1.4, however, as long as you add support for the Scanner class (this will satisfy the requirements for CS 101 and most other first-semester programming courses). You can go here for good and simple instructions on how to install the pseudo-Scanner class.

Using Java on your Mac

There are three main options for writing Java programs on your Mac: XCode, Eclipse, or the Terminal and a simple text editor.

Some Tips for Writing Mac-Friendly Programs


Tutorial written by Adrienne Felt. Last updated 10 September 2006.