Sie sind auf Seite 1von 3

Using JavaDoc in JCreator Introduction

Javadoc is a utility provided by the Sun SDK that generates HTML documentation for Java programs. The Javadoc utility creates customized documentation automatically from compiled Java files. However, to make your documentation more robust, you can add special directives in your Java file that will appear in the documentation. This pamphlet describes how to set up the Javadoc utility in JCreator, how to run the Javadoc utility from JCreator, and some directives you can use.

How to Set Up Javadoc in JCreator


The Javadoc utility can be found in the bin directory of your SDK or JDK directory. E.g., for me, since I installed JDK in Program Files in a folder called Java, it was found in C:\Program Files\Java\jdk1.5.0\bin. If you do not know where the Javadoc utility resides, you might want to perform a search on your hard drive for javadoc.exe before proceeding. 1) 2) 3) 4) 5) 6) 7) 8) Start JCreator. Select the Configure... Options from the menu bar. The Options dialog box appears. Select Tools from the left panel. Click the New command button. Select Program from the list. The Open dialog box appears. Navigate through your files and folders to find the javadoc.exe file. (Like I mentioned above, mine was in C:\Program Files\Java\jdk1.5.0\bin). 9) Double click the file or- click the Open command button. 10) Click the Apply button at the bottom of the Options dialog box. This adds the utility to the Tools menu in the left panel. 11) Select javadoc from the Tools menu in the left panel. 12) You will need to fill in the following information in this window: Arguments: -author -version -d "$[PrjDir]\docs" $[JavaFiles] Initial directory: $[PrjDir] 13) Click the OK command button. 14) To make sure you did this correctly, select Tools from the menu bar. javadoc is wrench item number one.

How to Run Javadoc in JCreator


Two things need to be completed before you can generate documentation using Javadoc. First, you must set it up to work on JCreator. Second, you must open or write a java project. The java project needs to be compiled every time you make a change to it and the Javadoc utility must be re-run so that the change is reflected in the documentation. 1) Open/create new project in JCreator. 2) Compile the project. 3) Select Tools... javadoc from the menu bar. 4) A DOS screen appears momentarily as the HTML documentation is created. If there is an error, you will see it in the DOS window and the window will remain open. If there is no error, the window closes automatically. 5) The HTML documentation is created in the current projects directory in a folder called docs. Navigate to this directory using Windows Explorer (My Computer). 6) In the project directory you will find a file named index.html. Open this file to see the documentation generated.

Documenting for Javadoc


Javadoc can take comments you have written in your code and create appropriate documentation. Following are some directions on commenting your java files for use with Javadoc. Your comments must be specially formatted so that Javadoc can read them. Comments that you want processed, must be enclosed in /** */ delimiters. Comments within the /** */ delimiters: 1. Can include HTML to make the final documentation more attractive. 2. Must always precede a class, field, method, or constructor declaration. 3. can include just text or END with block tags. Block tags direct Javadoc to do certain things and are explained below. Block tags have special meaning to Javadoc and always start with an @ symbol. Block tags must always be at the end of the comment block. Some block tags that are frequently used are: @author <text> @version <text> @return <text, null if void> @param <name of var> <text> @throws <name of exception> <text>

For more information


There is plenty of information at the Sun Java web site explaining how to use Javadoc. Most of it describes how to use Javadoc from the command prompt (not in JCreator). (You can compile your Java projects using the command prompt. You dont need an IDE like JCreator ) Here are two useful Javadoc URLs: http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html http://java.sun.com/j2se/javadoc/writingdoccomments/index.html

Das könnte Ihnen auch gefallen