Pure Danger Tech


Getting Java source on the Mac

21 Sep 2007

It’s been bugging me for a while that the JDK source is not included on the Mac version of Java and thus I can’t walk into the source in Eclipse. I finally got around to fixing that. If you want the source, you have to join the Apple Developer Connection (free account is fine) and find under the Java downloads the “J2SE 5.0 Release 5 Developer Documentation”. Download this (69 MB) and install the package. This will drop a src.jar, and the javadoc in both HTML and jar form at /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home.

This will add a src.jar into your Java 5 installation, which you can then point to by going into Eclipse -> Preferences -> Java -> Installed JREs and edit JVM 1.5.0. You’ll then need to select either classes.jar or all the jars and edit the Source Location. Point to src.jar in the directory above.

By default the API javadocs Eclipse uses for tool tips, javadoc help, etc are actually on the Sun web site. Works great except when you have no net connectivity… :) Now that you have the developer docs, the same pages are installed on your own machine, so that should be faster (and work on the plane). So, while you’re here, change your Javadoc location to point either to the new docs directory in Home or “Javadoc in archive” with docs.jar in Home (and a path of doc/api). Make sure to run “Validate…” before continuing.