Eclipse ${user} variable.

How irritating is it each time when creating a new class in a fresh eclipse install to have to change manually the code template to match your name, since by default it uses you OS user name in the @author javadoc tag in front of each class.
It’s even worst when you look at someone else code, which I tend to do a lot these days. I see things like @author X8932398 or @author UV330993. ( Why on earth Windows Admin gives this kind of username is beyond my knowledge ( maybe a limit of the platform =X )
The base idea is smart, to fetch the name of the user who write the code. I tend to really like to know the author(s) of the code I read.

There is a small “hack” which can put anything you want in this ${user} variable.
Rather than having to change the template manually, add -vmargs"cleverUserNameIWantToUseInSourceCode" to the shortcut you use to run Eclipse ( by right clicking on it, selecting properties and editing the target input field) :

C:/java/eclipse/eclipse.exe -vmargs"cleverUserNameIWantToUseInSourceCode"

Have not seen any side effects since it’s uses ;)
Thx Mat for the tip.


  1. Jared:

    Works for me…In NetBeans you can just configure this by I have spent hours on multiple occasion trying to figure this out and haven’t till I read you post just now.

  2. jreform:

    Doesn’t it save the username when you export preferences to a file?

  3. Chris:

    Thank you for the good tip! I noticed one side effect: I use Clear Case Remote in Eclispse and the user name in the “connect” dialog will be overwritten by the new user name. Not a big issue, but a little bit annoying.


  4. Tanmay:

    That did the trick. Thanks for the help.

  5. Devender:

    Thanks for the tip, I edited the eclipse.ini file and put the user name and that seems to work too.
    -Xmx256m R. Gollapally

  6. ${user} Template Variable in Eclipse setzen | sabel's blog:

    [...] gibts einen kleinen Tweak, mit dem man diesen User manuell beliebig setzen [...]

  7. Rustam:

    Anyone know if ${user} can be set per-project?

  8. lucasks:

    On a per-project basis you can go in to Code Templates, click on Configure Project Specific Settings and then change the templates. Then you can replace every instance of a variable with the value you want for a given project. A major pain I know but… it works.

  9. dovescrywolf:

    I used this method on my mac. Worked!
    This is what i did:
    navigated to the location of the app (in the application folder)
    >Show Package Contents
    Navigate: Contents>MacOS> open the eclipse.ini file

    and add this”cleverUserNameIWantToUseInSourceCode”

    thanks for this !!! much appreciated!

  10. Paddy:

    Worked for me as well, thanks for the tip ;)

  11. m:

    On windows xp & eclipse php (galileo):

    After settingé─¨cleverUserNameIWantToUseInSourceCodeé─¨

    The editor doesn’t work anymore:

    Could not open the editor: Editor could not be initialized.

  12. Jean-Laurent de Morlhon:

    Maybe you can try ommiting the quotes : ”

  13. Thomas Skowron:

    Setting user name in eclipse.ini works fine with Eclipse Galileo 3.5.1 on Windows XP SP3.
    Thanks very much!

  14. boardtc:

    Does anyone know how to do this in springsource tool suite which uses Galileo 3.5.1? There is no eclipse.ini but a config.ini which includes the likes of:

  15. DNC:

    This and the .ini file tips were wonderful. Thank you to both of you.

  16. Eclipse template variable:

    [...] information can be found here and here Eclipse, eclise.ini, template, template variable, {$date}, [...]

  17. Anand Kumar:

    it works :)

  18. prem:

    author name does not show up in newly created files, how to make it added as comments while creating the file

  19. petr:

    Hi, change your eclipse.ini

    -Dosgi.requiredJavaVersion=1.5 name …. Jozko Mrkvicka :)

Leave a comment