Is there a way to generate Javadoc comments in Eclipse? If so, what is it?
-
I tried the alternate answer(2 years ago) and didn't like it, so consider it a dup or not. – antony.trupe Aug 30 '11 at 21:53
-
Duplicate or not, this is the top result when googling "eclipse generate javadoc" – Holloway Nov 12 '15 at 11:09
5 Answers
For me the /**<NEWLINE>
or Shift-Alt-J (or ⌘-⌥-J on a Mac) approach works best.
I dislike seeing Javadoc comments in source code that have been auto-generated and have not been updated with real content. As far as I am concerned, such javadocs are nothing more than a waste of screen space.
IMO, it is much much better to generate the Javadoc comment skeletons one by one as you are about to fill in the details.

- 8,989
- 7
- 48
- 78

- 698,415
- 94
- 811
- 1,216
-
17
-
29@Pascal - I'd prefer to delete it/them, or not generate it/them in the first place. IMO, generated javadoc comments add zero value ... unless you count a bogus boost to the comment-to-code ratio as "value". – Stephen C Nov 22 '09 at 02:54
-
5important note: If using shift-alt-j, don't forget to place the cursor first in the method you want to document otherwise your comment will be added at the top of the file for the class. – thedrs Oct 13 '16 at 07:38
Shift-Alt-J
is a useful keyboard shortcut in Eclipse for creating Javadoc comment templates.
Invoking the shortcut on a class, method or field declaration will create a Javadoc template:
public int doAction(int i) {
return i;
}
Pressing Shift-Alt-J
on the method declaration gives:
/**
* @param i
* @return
*/
public int doAction(int i) {
return i;
}

- 159,216
- 35
- 211
- 226
-
23
-
2You just made my life SOOOOO much better! I'll thank you every time I use shift-alt-J -- and every time I look brilliant when I show it to coworkers! – Redboots Aug 29 '14 at 16:37
an Eclipse Plugin for automatically adding Javadoc and file headers to your source code. It optionally generates initial comments from element name by using Velocity templates for Javadoc and file headers...

- 6,213
- 108
- 53
- 73

- 10,640
- 10
- 57
- 84
You mean menu Project -> Generate Javadoc ?

- 7,883
- 1
- 32
- 23
-
-
It's on my Eclipse, and the only extra things I've installed are Google Web Toolkit and FindBugs. (This is Ganymede, not Europa. Maybe you need to upgrade?) – Paul Tomblin Nov 21 '09 at 23:56
-
-
2Maybe you need to install Eclipse for Java Developers or Eclipse for J2EE developers. – Jherico Nov 22 '09 at 00:00
-
What happens if you go to Preferences->Java->Code Templates and click "restore defaults"? Because I have code templates for comments that includes all the javadoc stuff. – Paul Tomblin Nov 22 '09 at 00:01
-
it appears all the templates are present. I clicked "restore defaults" to be sure nothing crazy is going on. I just don't have that menu option. My hunch is I have a subset of the "usual" features of eclipse. – antony.trupe Nov 22 '09 at 00:05
-
2Anyway, this is not what the OP is looking for. The question (which is a bit misleading) is not about generating the javadoc but adding javadoc "comments" in the code. – Pascal Thivent Nov 22 '09 at 00:35
At a place where you want javadoc, type in /**
<NEWLINE> and it will create the template.

- 97,814
- 39
- 186
- 310
-
1. that works, thank. 2. that menu item isn't in any of the perspectives I use. – antony.trupe Nov 21 '09 at 23:59
-
-
1Generate Javadoc does not generate Javadoc comments. It parses Javadoc comments and generates project documention (usually HTML) – ebelisle Jan 03 '12 at 18:37