Sign in to follow this  

[java] Javadoc please help

This topic is 4279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have doenloaded SDK 5. I am on windows. I am trying to run javadoc from cmdline. So far I have been able to document a single main .java file. Now I want also to document all the packages in the subdirectories of my program. In the example showen on the sun website, they only show how to create documents of the standard library of java. So basically I want it to document my whole program. The "main" java file and all the packages. Everything in my src. How do I do this? Thanks in advance.

Share this post


Link to post
Share on other sites
The answer to this is in your API under Tools, and then Javadoc. Checkout the help for javadoc -help

also here is the documentation in the api for this -- but you should really read the api about the javadoc tool, there is likely to be a better and easier way...and then after that start using Ant (at apache.org), it will help (but its not the answer for everything.)


SIMPLE EXAMPLES
You can run javadoc on entire packages or individual source files. Each package
name has a corresponding directory name. In the following examples, the source
files are located at C:\home\src\java\awt\*java. The destination directory is
C:\home\html.

Documenting One or More Packages

To document a package, the source files (*.java) for that package must be
located in a directory having the same name as the package. If a package name
is made up of several identifiers (separated by dots, such as java.awt.color),
each subsequent identifier must correspond to a deeper subdirectory (such as
java/awt/color). You may split the source files for a single package among two
such directory trees located at different places, as long as -sourcepath points
to them both -- for example src1\java\awt\color and src2\java\awt\color.

You can run javadoc either by changing directories (with cd) or by using -
sourcepath option. The examples below illustrate both alternatives.


Case 1 - Run recursively starting from one or more packages - This example
uses -sourcepath so javadoc can be run from any directory and -subpackages (a
new 1.4 option) for recursion. It traverses the subpackages of the java
directory excluding packages rooted at java.net and java.lang. Notice this
excludes java.lang.ref, a subpackage of java.lang).

% javadoc -d \home\html -sourcepath \home\src -subpackages java -exclude
java.net:java.lang

To also traverse down other package trees, append their names to the -subpackages argument, such as java:javax:org.xml.sax.

Case 2 - Run on explicit packages after changing to the "root" source
directory - Change to the parent directory of the fully-qualified package. Then
run javadoc, supplying names of one or more packages you want to document:

C:> cd C:\home\src C:> javadoc -d C:\home\html java.awt java.awt.event

Case 3 - Run from any directory on explicit packages in a single directory
tree - In this case, it doesn't matter what the current directory is. Run
javadoc supplying -sourcepath with the parent directory of the top-level
package, and supplying names of one or more packages you want to document:

C:> javadoc -d C:\home\html -sourcepath C:\home\src java.awt java.awt.event

Case 4 - Run from any directory on explicit packages in multiple directory
trees - This is the same as case 3, but for packages in separate directory
trees. Run javadoc supplying -sourcepath with the path to each tree's root
(colon-separated) and supply names of one or more packages you want to
document. All source files for a given package do not need to be located under
a single root directory -- they just need to be found somewhere along the
sourcepath.

C:> javadoc -d C:\home\html -sourcepath C:\home\src1;C:\home\src2 java.awt
java.awt.event

Result: All cases generate HTML-formatted documentation for the public and
protected classes and interfaces in packages java.awt and java.awt.event and
save the HTML files in the specified destination directory (C:\home\html).
Because two or more packages are being generated, the document has three HTML
frames -- for the list of packages, the list of classes, and the main class
pages.





L-

Share this post


Link to post
Share on other sites

This topic is 4279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this