Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comment style for license headers in Java [closed]

Tags:

java

licensing

It is recommended to add a license-header to the top of each file that includes Copyright and licensing informations (e.g. GPL3 suggests adding this). Is there a standard comment-style to use for the license header in Java or can I use whatever I like?

I know that the License Maven Plugin suggest using Javadoc-styled comments and this is what I am using right now, but recently discovered that some projects use simple multi line commends (just a single *) instead. Will Javadoc-like comments produce problems when using the Javadoc tool?

like image 258
thee Avatar asked Sep 27 '14 13:09

thee


1 Answers

You should use /* */, it seems to be the standard in the majority of open source java projects. Javadoc should be used to describe Java classes, interfaces, constructors, methods, and fields.

However, if you want to use a Javadoc I guess you can, and it will not get on your way if you put an import statement just after it. According to this documentation on placement of comments:

A common mistake is to put an import statement between the class comment and the class declaration. Avoid this, as the Javadoc tool will ignore the class comment.

/**
* This is the class comment for the class Whatever.
*/

import com.sun;   // MISTAKE - Important not to put import statement here

public class Whatever {
}
like image 197
Luís Ramalho Avatar answered Nov 07 '22 09:11

Luís Ramalho