Getting Java source on the Mac
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.
Enjoy!

Hi! My name is Alex Miller and I live in St. Louis. I write code for a living and currently work for
Cheers Alex – I’m off to do just that….
Hey, I was just getting irritated enough the other day to search for what to do, but didn’t find anything. You’re the man!
Great tip! A source attachment is always the first thing I do on my Linux workstation, but I didn’t do this on my Mac. I’ll try it out shortly, but does this also include the source for the internal classes?
For the Sun JDK, the source for the public classes comes with the JDK, but the source for the internal classes is a separate download from the development website (the one where the development for the JDK itself is hosted).
Hmmm, a quick look says probably not. The src.jar includes all the expected java, javax, corba stuff and some sun classes for corba and plaf, but not much else. So, I guess I’d say no. I’m sure some of that stuff is Apple specific and thus probably not released. But, they license the JDK from Sun so you might find that the Sun version is mostly the same. That’s just theory on my part though.
I’ve tried to install the java_for_mac_os_x_10.5_documentation.dmg on MacOS10.5 but have no clue where something is installed. I can’t find a src.jar anywhere. Hmm, how do I uninstall that package?
Mike, you should see the src.jar at the path I had in the post. There is no uninstall as far as I know. You can just delete src.jar, docs.jar, and appledocs.jar from that directory if you want.
I have 10.5 also, it’s just not there, man. install all you want, it’s gone. and the 10.4 installer wont work either.
Ah, I missed the “10.5″ part. I’ve recently upgraded to Leopard and I still have everything but I installed on 10.4. When I get a chance I’ll see if I can find a solution.
Until there is an official mac source version I ended up downloading the jdk-1_5_0-src-scsl.zip from sun and pointed the eclipse jdk source property to that file. While this allows jdk source to be opened for browsing I’m not sure how applicable it will be for debugging.
For some reason it didn’t work for me, then installer sad that there is a newer java version and quit :(
Yet, I succeeded attaching the sources the hard way:
– going to Sun’s website and downloading the J2SE 5.0 JDK Source Code (SCSL) zip
– extracting the zip file into a folder (lets say “jdk-1_5_0-src-scsl”)
– configuring the IDE (in my case IntelliJ) to point to “jdk-1_5_0-src-scsl/j2se/src/share/classes”
Hope it’ll help someone…
The files are installed on leopard on the location where xcode installs the files as well.
/Developer/Documentation/DocSets
If you need the sources on Leopard, you’ll need to “Show Package Contents”, then unzip the 69MB .gz file inside — the installer doesn’t want to work otherwise.
Cheers :)
Why this isn’t all done by default……
The current best directions for this I’ve seen (supersedes mine above).