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?
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 {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With