When I'm working closely with a Java API, I will usually find myself, sooner or later, digging into the API source code (if it is available) to see how a feature really works. This usually means finding the separate source download (or even configuring CVS to pull the code from some repository someplace). A pain in the neck to say the least, but the code provides the definitive description of what is going on, so sometimes it's worth it. However, all the pain of finding, downloading, unpacking and browsing the source can be eliminated.

Since version 1.4, JavaDoc has included a '-linksource' option that will automatically create an HTML version of each source file and link it into the normal documentation. With the -linksource option, the class and method names in the docs will contain links to the source code. When browsing docs built with the -linksource option, I don't have to break away from the docs to find the corresponding source file, it is all right there in the docs. For an example of how this work check out the JFreeChart API docs.

Comments:

If you use Eclipse, you can also mount source jars to project. If you shift-click on a method, it brings you directly to (read-only) method source.

Posted by Tanel A on April 20, 2005 at 08:39 AM EDT #

The problem is, with -linksource it's not necessary to have the source jars...

Posted by Anonymous Joward on April 20, 2005 at 09:55 AM EDT #

This is very nice. Thanks for the tip.

Posted by 199.21.28.13 on April 21, 2005 at 10:18 AM EDT #

yes, this is a javadoc feature that many people don't really know about. i've been working on resurrecting my old dbdoc.org site. i haven't officially launched it yet but it's up at superjavadocs.org or openjavadocs.org i'd be curious to know what you think. thanks. / eitan

Posted by eitan on April 26, 2005 at 09:34 PM EDT #

Post a Comment:

This blog copyright 2010 by plamere