Tuesday, 29 November 2011

How to Change Default Author Name for JavaDocs in Eclipse?


In Eclipse we always try to generate the Java docs at the class level or method level. But when we generate the Java docs it picks the user name from the system user. This could result in weird author names in your code files as in an organization usernames are usually as per organizational naming conventions.For example my user name that I use to login is ORG001239 something like  and you will agree that it wouldn't look good as an author name in a Java file and might not make any sense to most other viewers of the code.

/**
 * Test default author in JavaDocs
 * @author ORG001239
 */
public class TestClass {
}

Here is a quick way to change the default author name in your Eclipse projects. Simply edit your eclipse.ini file found in the root directory where you placed Eclipse. I have Eclipse at C:\eclipse, so my path would be C:\eclipse\eclipse.ini. Once editing this file add the following line and save.

-Duser.name=Saket Saraf

After saving restart Eclipse and when you do a JavaDoc comment and use the author attribute by typing @author and pressing enter on the autocomplete you will see something like this:


/**
 * Test default author in JavaDocs
 * @author Saket Saraf
 */

public class TestClass {
}


Source
http://www.javagyan.com

No comments:

Post a Comment