Wednesday, October 24, 2012

Create JavaDoc


Pre-Requisites:
  • jdk1.6.0_11

Installed location:
jdk1.6.0_11                 ->   C:\Program Files\Java\jdk1.6.0_11\

Environment Variables:
Enter Variable name and Variable value which is mentioned below.

Variable name:JAVA_HOME
Variable value:C:\Program Files\Java\jdk1.6.0_11

Overview:
Javadoc is a tool for generating API Documentation in HTML format from doc comments in source code.
Save as CreateJavadocExample.java
  1. /* 
  2.  * @(#)CreateJavadocExample.java 1.0 07/15/09 
  3.  * 
  4.  * Copyright 2009 Java Workspace, Inc. All rights reserved. 
  5.  * JAVA WORKSPACE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 
  6.  */  
  7.   
  8. package com.javaworkspace.javadoc;  
  9.   
  10. /** 
  11.  * The class <code>CreateJavadocExample</code> includes method for adding two 
  12.  * numbers 
  13.  *  
  14.  * <p> 
  15.  * For additional information on Javadoc, see <a *="" href="http://www.javaworkspace.com/createJavaDoc.do">http://www.javaworkspace.com/createJavaDoc.do</a>. 
  16.  * </p> 
  17.  *  
  18.  * @author www.javaworkspace.com 
  19.  * @version 1.0, 07/15/09 
  20.  * @see java.lang.Object 
  21.  * @since 1.0 
  22.  */  
  23.   
  24. public class CreateJavadocExample {  
  25.   
  26.     /** 
  27.      * @param a 
  28.      *            first number which is to be added 
  29.      * @param b 
  30.      *            second number which is to be added 
  31.      * @return addition of two numbers 
  32.      * @since 1.0 
  33.      */  
  34.   
  35.     public int add(int a, int b) {  
  36.         return a + b;  
  37.     }  
  38. }  

Steps To Create JavaDoc
  1. Copy the above program in the folder com.javaworkspace.javadoc
  2. In command prompt navigate to D:\javadoc\com\javaworkspace\javadoc>
  3. type javadoc CreateJavadocExample.java
  4. this will create html document in the same folder.
  5. Locate index.html and click that.
  6. Browser window will be opened with Class Summary.
  7. Click CreateJavadocExample in top left corner of All Classes pane.
  8. You can see Method Detail,  Detail... etc.
  9. In the above example we have mentioned only some of the javadoc comments.

1 comment: