tags:

views:

199

answers:

1

When trying to create package level Javadoc comments, whats the preferred method? What do you do?

Package-info.java

  • Pros
    • Newer
  • Cons
    • Abuse of a class - Classes are for code, not for only comments

Package.html

  • Pros
    • HTML extension means its not code
    • Syntax highlighting in IDE's/text editors
  • Cons
    • None?

For me, I've always used Package.html. But I'm wondering if its the correct choice.

+3  A: 

package-info.java: "This file is new in JDK 5.0, and is preferred over package.html."—javadoc - The Java API Documentation Generator

Addendum: The big difference seems to be package annotations. There's a little more in the way of rationale in 7.4 Package Declarations.

Addendum: The annotation feature is also mentioned here and here.

trashgod
I did _not_ know that!
trashgod
Any particular reason why its preferred?
TheLQ
@TheLQ: I'm guessing package annotations, as the compiler has more information to work with; more above.
trashgod
Package annotations are new to me, and seem a good reason for package-info.java due to its scope.
stacker
@stacker: I think you're right; more links above.
trashgod