127

I dislike the default Javadocs generated for me when I create a Class or methods, especially the @author variable, which is the current system username on my windows box.

I would like to change it. Is this possible?

Olaseni
  • 7,698
  • 16
  • 44
  • 68
  • 2
    For the `@author` variable customization, you can set up your custom string by editing `eclipse.ini` file adding `-Duser.name=customstring` (Tested in **Kepler / Luna**) – KrishPrabakar Feb 27 '15 at 03:42
  • 3
    You better get rid of `@author` tag, as it is an [unwanted noise](https://stackoverflow.com/a/17271433/1800052). – Alexander Pozdneev Sep 13 '17 at 10:01

5 Answers5

192

Check Preferences / Java / Code Style / Code Template

Section Comment / Type

You can replace the author tag by whatever value you need and it will have an effect on new generated classes.

Code Templates


However, if the template is fine, but the value referenced buy the author tag is not, see this SO question:

${user} uses the value of the user.name environment variable; therefore, you can pass -Duser.name=My Name in eclipse.ini to override it.

Or, if you prefer, you can modify the shortcut to point to:

C:/java/eclipse/eclipse.exe -vmargs -Duser.name="cleverUserNameToUseInSourceCode"

  • MacOs: Aram Kocharyan mentions the eclipse.ini is in Eclipse.app/Contents/MacOS/ if you right click and go Show Package Content.
  • ZendStudio: rofflox comments the file is named ZendStudio.ini and is found in Applications/Zend Studio.app/Contents/MacOS/.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 6
    Unrelated: How did you generate such a pretty screenshot? – Paul Lammertsma Apr 11 '10 at 02:19
  • 1
    @Paul: after that meme revealed itself as "mandatory" (http://meta.stackexchange.com/questions/19478/the-many-memes-of-meta/19775#19775), I had to use FSCapture (http://www.faststone.org/FSCaptureDetail.htm) to comply ;) – VonC Apr 11 '10 at 10:02
  • Snipping Tool does the trick on Win7. Thanks for the screenshot. This is just what I needed tonight! :) – Joseph Lust Jan 30 '12 at 04:28
  • 1
    For Mac users, eclipse.ini is in Eclipse.app/Contents/MacOS/ if you right click and go Show Package Contents – Aram Kocharyan Aug 04 '12 at 15:38
  • The same goes for Zend Studio for Mac. The `ZendStudio.ini` is found in `Applications/Zend Studio.app/Contents/MacOS/`. – Roman May 31 '13 at 08:30
  • Although this is not the answer what I want, this helps to get to the answer. I need to start each file with commented copyright and that can be done by editing `Files` instead of `Types`. – Ramsharan Jul 16 '13 at 02:00
  • eclipse.ini has moved to Eclipse.app/Contents/Eclipse – Michael Fulton Mar 28 '17 at 18:29
  • @MichaelFulton Do you mean on Mac? Strange, because https://wiki.eclipse.org/Eclipse.ini still indicated `/MacOS/` – VonC Mar 28 '17 at 20:27
  • @VonC Hm. This is just where it was for me. I installed Neon.3 using the installer and looked for Eclipse.ini moments later. – Michael Fulton Mar 28 '17 at 20:29
6

Look at Window -> Preferences -> Java -> Editor -> Templates.

Binil Thomas
  • 13,699
  • 10
  • 57
  • 70
  • Yeah I know about that, but unfortunately this does not seem to have any effect on the code generation for Classes. I want to avoid having to do this manually – Olaseni Apr 10 '10 at 07:51
3

Spring Tool Suite (popular Eclipse customization for Spring development) uses STS.ini. On Windows I found it in the same dir as an app launch executable.

3

To use a Git username and email you can use the variables ${name:git_config(user.name)} and ${email:git_config(user.email)}.

enter image description here

chrisjleu
  • 4,329
  • 7
  • 42
  • 55
1

You should consider using JAutodoc, which is a very useful plugin for Eclipse. The parametrization is way more advanced than the standard Eclipse generation.

Julien
  • 1,302
  • 10
  • 23
  • Is there a way to replace the eclipse javadoc generation of eclipse with JAutoDoc? What I mean is: I have installing the JAutoDoc plugin. If I now generate get/setter methods via Shft+Alt+S and selecting "Generate Getters and Setters..." the javadoc comments are still generated by eclipse. But I want to generate this comments by JAutoDoc automatically... – Steffen Jan 09 '15 at 08:31