Customise auto-generated Comment when Creating New Class in Eclipse (Juno 1.5.1)

Create New Class in Eclipse
Tags:

When creating a new class in Eclipse via File > New > Class, please ensure that you had ticked the checkbox ‘Generate comments‘ if you wish there are useful comments included in the new class.

The auto-generated comment is as following:

/**
 *
 */
package com.chapter7.arrays;

/**
 * @author mychin
 *
 */
public class Exercise713 {

/**
 * @param args
 */
 public static void main(String[] args) {
 // TODO Auto-generated method stub

}

}

I would prefer to have useful information included in the file so that I can know the date and time that I had created the file. In order to customise the auto-generated comment, here are the following steps:

1. Under Eclipse > Preferences

2. Expand the ‘Java‘ section on the left sidebar

3. Choose Code Templates via Java > Code Style

4. Expand the ‘Comments‘ section and choose ‘Types‘.

5. By default, the pattern is as following:

/**
 * @author ${user}
 * ${tags}
 */

In order to customise the comment and add the date and time, you need to customise the pattern as following:

/**
 * @author ${user}
 * @date ${date}
 * @time ${time}
 * ${tags}
 */

After the customisation, when you create a new file, it will look like this:


/**
 *
 */
package com.chapter7.arrays;

/**
 * @author mychin
 * @date Nov 30, 2012
 * @time 11:06:05 PM
 */
public class trying {

/**
 * @param args
 */
 public static void main(String[] args) {
 // TODO Auto-generated method stub

}

}

Article Global Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon Eli Pets


Rate This Post

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>