10

How can I add java docs to my java program using netbeans?

2
  • Javadocs are comments that start with /** and come in front of classes and methods. You just type them. What more do you want? What are you asking? Commented Feb 17, 2010 at 11:46
  • multiple versions of NB have multiple methods to generate 'skeleton' javadoc comments for code... you may want to identify the version of NetBeans that you want info about. Commented Feb 17, 2010 at 15:47

3 Answers 3

33

You have a number of options:

  • Right-click on a source package and select Tools > Analyse Javadoc. This will add Javadoc to all methods
  • Type /** on the line before a class, method or field declaration, and then press Enter. Default Javadoc will be created for that method
  • Place the cursor within a class or method declaration. Press Alt + Enter, and then select "Create Javadoc"
Sign up to request clarification or add additional context in comments.

5 Comments

This applies to NetBeans 6.8, right? Does it apply to earlier versions?
I've tried the first and third options on earlier versions of Netbeans than 6.8. I'm fairly sure they work on 6.5. Not so sure about the second one: I've only tried that on 6.8.
The first form has been there for quite a while (3 or 4 I think). However in pre-6 release it's available by right-clicking on the class in the projects window and was called something like "Autocorrect Javadoc". The second form has been there since 4 or 5. The third form was introduced in NB6.
In every javadoc theres some link of another java doc, How do I make a link?
ALT + ENTER in macOS would be? Option + Return is not doing it
7

On the line above any method or class, type /** and hit enter.
Enter your comments in between.

Comments

2

Also, use the

@param

tag to specify parameters in a Javadoc:


 /**
  *
  * A method
  *
  * @param abc Used to do nothing
  */
 public static void doNothing(int abc) {
   System.out.println(abc);
 }

You can also use the Alt+Enter combination in Netbeans to automatically insert the Javadoc with all parameters, however remember that this method/field can't be private.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.