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 -Duser.name="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 -Duser.name="cleverUserNameIWantToUseInSourceCode"
Have not seen any side effects since it’s uses ![]()
Thx Mat for the tip.
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 October 2007, 5:41 amjreform:
Doesn’t it save the username when you export preferences to a file?
5 February 2008, 12:08 amChris:
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.
Chris
8 February 2008, 11:00 amTanmay:
That did the trick. Thanks for the help.
3 April 2008, 10:47 pmDevender:
Thanks for the tip, I edited the eclipse.ini file and put the user name and that seems to work too.
27 April 2008, 12:45 am-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize256M
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx256m
-Duser.name=Devender R. Gollapally
${user} Template Variable in Eclipse setzen | sabel's blog:
[...] gibts einen kleinen Tweak, mit dem man diesen User manuell beliebig setzen [...]
25 June 2008, 12:53 pmRustam:
Anyone know if ${user} can be set per-project?
3 October 2008, 4:54 pmlucasks:
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.
19 November 2008, 8:41 pmdovescrywolf:
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 -Duser.name=”cleverUserNameIWantToUseInSourceCode”
thanks for this !!! much appreciated!
24 August 2009, 1:22 pmPaddy:
Worked for me as well, thanks for the tip
8 September 2009, 5:15 amm:
WARNING
On windows xp & eclipse php (galileo):
After setting
-Duser.name=cleverUserNameIWantToUseInSourceCode
The editor doesn’t work anymore:
Could not open the editor: Editor could not be initialized.
6 November 2009, 4:15 pmJean-Laurent de Morlhon:
Maybe you can try ommiting the quotes : ”
6 November 2009, 4:37 pmLike
-Duser.name=cleverUserNameIWantToUseInSourceCode
Thomas Skowron:
Setting user name in eclipse.ini works fine with Eclipse Galileo 3.5.1 on Windows XP SP3.
10 December 2009, 11:10 amThanks very much!
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:
4 March 2010, 6:00 pmeclipse.p2.data.area=@config.dir/../p2/
eclipse.application=org.eclipse.ui.ide.workbench
DNC:
This and the .ini file tips were wonderful. Thank you to both of you.
9 August 2010, 11:27 pmEclipse template variable:
[...] information can be found here and here Eclipse, eclise.ini, template, template variable, {$date}, [...]
27 August 2010, 3:36 pmAnand Kumar:
it works
10 September 2010, 5:34 pmthanks
prem:
author name does not show up in newly created files, how to make it added as comments while creating the file
7 January 2011, 5:26 ampetr:
Hi, change your eclipse.ini
3 February 2011, 9:29 pm…
….
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Duser.name=Author name …. Jozko Mrkvicka
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m