0

I understand that Javadoc is a documentation generator from Sun Microsystems for generating API documentation in HTML format from Java source code. I infer that the documentation is stored onto an HTML file.

Is there a way I can access it?

If yes where is it stored?

4

1 回答 1

2

The word Javadoc can refer to

  • special comments in Java source files (preceding a declaration, and of the form /** ... */)
  • a program which converts these comments (as well as the declarations themselves) to readable output
  • the output itself, usually in HTML form.

The Javadoc program is contained in Sun's (or now Oracle's) Java Development Kit (JDK).

If you have installed a JDK (which you should if you do Java development), you can call it on the command line, passing it the package names to document, or some source file names. You should also indicate the output directory, using the -d option.

I'm assuming the following directory (and package) structure in my example below:

  • current directory
    • source
      • de
        • dclj
          • paul
            • examples
              • HelloWorld.java [containing package de.dclj.paul.examples; and public class HelloWorld { ... }]
    • docs
Then you use the following command line:

javadoc -sourcpath source -d docs de.dclj.paul.examples

It will then create a the documentation in the docs directory, with an index.html which you can open in your web browser, and other files reachable from it.

For more details have a look at the documentation linked above. For an example output, have a look at the Java Standard API Javadoc.

If you are using an IDE, you likely have a generate Javadoc button there, and the IDE might even show the formatted output of documentation of single classes or methods on the fly.

于 2012-09-22T18:29:27.617 回答