Creating JavaDocs in Eclipse
by, 11-09-2011 at 06:42 PM (4347 Views)
Java Docs are of great importance for Java programmers. Every Java programmer uses it to know which functions are to be used to achieve the results.
Java Docs provide useful information including:
- Which classes exist in a package
- Purpose of each class
- Constructors in a class
- Methods in a class
- Method parameters and return types
- Deprecated methods
- Exceptions that a method raises
- Version and Author of the class
Now can we generate Java Docs for our packages/classes. The answer is yes. Java provides javadoc.exe for this purpose. I will show you how to use it in Eclipse to generate JavaDocs.
I assume that you know the basis of Eclipse and can create packages and classes. Lets move ahead. You have to annotate your code with comments to make javadoc.exe understand your packages/classes/constructors/methods.
JavaDoc comments are easy. They start with a forward slash and two asterisks (/**) and ends with one asterisk and a forward slash (*/).Everything between the delimiters (even if it spans multiple lines) is a comment.
* @author Laiq
* This is a test class.
* JavaDoc Comments are useful.
To generate Java Docs for your project, you have to the following:
Click Project from the Eclipse menu bar and select JavaDoc.
Browse to the javadoc.exe file, then select all the projects for which you want to generate the docs and finally select the basic options and proceed.
Now you will have the generated documents.
javadoc.exe will convert source file's JavaDoc comments into an HTML JavaDoc file which is very useful for the developers especially if they are working in a team.