JMakeDepend has been enhanced since the version described in Chapter 48 of the book. The version in the book (the "old" version) can generate Makefile dependencies for projects whose source files all reside in the current directory - as in the example in Chapter 48. The enhanced version provided on the CD-ROM supports projects with sources distributed in subdirectories. A common practice in Java projects is to distribute the sources among subdirectories - typically (but not necessarily) reflecting the package hierarchy. The sources are built with a single compiler invocation in order to satisfy the mutual dependencies. So a project with many sources resident under the src/ subdirectory may be built like this: find src -name '*.java' -print >sources javac -d classes @sources This can lead to long build times for large projects: JMakeDepend can improve this by not building sources that do not need to be rebuilt. An important part of JMakeDepend's logic is the ability to locate the source file corresponding to a particular class file: the old version could only locate sources in the current directory, the enhanced version can locate sources in a number of places. Here are some examples of how to use JMakeDepend: Sources in Current Directory ---------------------------- This is the case demonstrated in chapter 48. Pass the class file names, either on the command line or through stdin, to JMakeDepend. Example: find classes -name '*.class' -print | java com.macmillan.nmeyers.JMakeDepend Sources in a Package-Structured Source Tree ------------------------------------------- If the sources are in a tree that reflects the package name, you can use the -sourcepath option to designate the tree. (As an example of this structure, source code for class foo.bar.Baz in a tree under the directory sources/ would be found in sources/foo/bar/Baz.java.) The -sourcepath option is used in the same way as with javadoc, for example: find classes -name '*.class' -print| java com.macmillan.nmeyers.JMakeDepend -sourcepath sources Sources in Arbitrary Locations ------------------------------ For sources in arbitrary locations - not the current directory and not in any sourcepath - you can feed the source file names to JMakeDepend as part of the input; it will match the class and source file names. For example, if such sources live under the src/ subdirectory, this invocation will find them: find classes src -name '*.class' -print| java com.macmillan.nmeyers.JMakeDepend -sourcepath sources