sdoca
sdoca

Reputation: 8042

Eclipse: Insert Type Javadoc in New Classes Automatically

I'm using Eclipse Neon. I have updated Window -> Preferences -> Java -> Code Style -> Code Templates -> Comments -> Types to include a copyright notice in the class javadoc:

/**
 * @author My Company ${year} 
 *
 * ${tags}
 */

Under Code Templates -> Code -> New Java files it has:

${filecomment}
${package_declaration}

${typecomment}
${type_declaration}

However, when I create a new Java class via the New wizard (either right click the package or from the File -> New menu, it doesn't insert the class javadoc.

Can I set Eclipse to add this when a new class is created?

Upvotes: 1

Views: 1360

Answers (2)

Shrirang Kumbhar
Shrirang Kumbhar

Reputation: 363

Another way : You can update "Code Templates -> Code -> New Java Files" as below:

${filecomment}
${package_declaration}

${typecomment}

/**
 * @author My Company ${year} 
 *
 * ${tags}
 */
${type_declaration}

With this we don't need to check 'Generate comments' check box on the New Class dialog

Upvotes: 0

greg-449
greg-449

Reputation: 111142

There is a 'Generate comments' check box on the New Class dialog that controls if the comments are added.

The default for this check box come from the 'Java > Code Style > Code Templates' preference page - the 'Automatically add comments to new methods and types' check box at the bottom of the page.

Upvotes: 1

Related Questions