JAVATM MASTER

JavaDocTM

Back to Table of Contents

You use the javadoc command similar to how you use the javac command which comiles java code. Unlike javac, javadoc does not compile code, but creates javaTM documentation in the form of HTML code:

See http://java.sun.com/j2se/1.3/docs/api/index.html for the javadoc on the complete java 2 Platform v 1.3.1.

See http://java.sun.com/j2se/1.4/docs/api/index.html for the javadoc on the complete java 2 Platform v 1.4.0.

See http://java.sun.com/j2se/1.5.0/docs/api/index.html for the javadoc on the complete java 2 Platform v 5.0.

See http://java.sun.com/javase/6/docs/api/ for the javadoc on the complete java 6 Platform v 6.0.

you can make your own javadoc for your own classes by typing the following command in your command prompt:

javadoc mypackage\myjavafile.java or

javadoc mypackage/myjavafile.java

depending on your operating System. "/" is used for Unix or Linux, and "\" is used for Windows based operating systems as a separator. Mac OS X operating systems are also Unix based. You can also see how to use javadoc by just typing javadoc in the command prompt by itself. Now, to get any meaningful java documentation, you have to put special comments into your code that is read by the javadoc parser. Here is an example:

/**
 * This first sentence shall appear in the method summary of the javadoc 
 * documentation. These further sentences shall appear in the method
 * detail section of your javadoc documentation.
 * @param MyVarName The int that supplies a number to do such.
 * @param MyNextVariable The String that is supplied to do
 * another thing.
 * @return An int that signifies something.
 * @throws Exception The generic Exception that can be thrown.
 */
 public int demonstrateJavaDoc(int MyVarName, String MyNextVariable)
 	throws Exception{
 	return MyVarName + MyNextVariable.length();
 }

You can also javadoc class variables: These are variables that are declared outside any method. The following is an example:

/**
 * This first sentence shall appear in the field summary. These further
 * sentences shall appear in the field Detail.
 */
 public String MyString = "I am a String";

Be sure you have the comments start as /** and end as */ with every line between those two points beginning with a asterisk ('*'). If you fail to meet that criteria, the javadoc parse will ignore your comments. Also, your comments are to immediately precede the code segment (methods, fields, and classes) that they are describing in order for your javadoc to work.

*OracleTM and JavaTM are registered trademarks of Oracle and or its affiliates. Other names may be trademarks of their respective owners.*