Java Reference
In-Depth Information
gument when compiling. This argument must be followed by the name of an existing direct-
ory (often . is used to signify the current directory) to specify where to build the directory
tree. For example, to compile all the .java files in the current directory, and create the direct-
ory path under it (e.g., create ./com/darwinsys/util in the example):
javac -d . *.java
This creates the path (e.g., com/darwinsys/util/ ) relative to the current directory, and puts the
class files into that subdirectory. This makes life easy for subsequent compilations, and also
for creating archives, which I will do in Archiving with jar .
Of course, if you use a build tool such as Ant (see Automating Compilation with Apache
Ant ) or Maven (see Automating Dependencies, Compilation, Testing, and Deployment with
Apache Maven ) , this will be done once in your configuration file (Ant) or done correctly by
default (Maven), so you won't have to remember to keep doing it!
Note that in all modern Java environments, classes that do not belong to a package (the “an-
onymous package”) cannot be listed in an import statement, although they can be referred to
by other classes in that package.
Documenting Classes with Javadoc
Problem
You have heard about this thing called “code reuse” and would like to promote it by allowing
other developers to use your classes.
Solution
Use Javadoc. Write the comments when you write the code.
Discussion
Javadoc is one of the great inventions of the early Java years. Like so many good things, it
was not wholly invented by the Java folks; earlier projects such as Knuth's Literate Program-
ming had combined source code and documentation in a single source file. But the Java folks
did a good job on it and came along at the right time. Javadoc is to Java classes what “man
Search WWH ::




Custom Search