Reputation: 891
When a new package is being created in Eclipse Juno, a java file (package-info.java) would be created automatically. What is the use of that file? Is it useful in importing specific classes in another class?
Upvotes: 35
Views: 17551
Reputation: 43969
It can be used for documentation on package level. For instance, the Spring Team uses it quite extensively in the core of the Spring Framework.
Beside that, it can contain annotations that apply to all classes in the package. For instance, it is a convenient way to avoid writing the NonNullByDefault annotations for the Eclipse Null Analysis on each class.
Note that for applying an annotation to a package, a file by the name package-info.java is used.
Upvotes: 5
Reputation: 14223
package-info.java
is a package comment file, used by Javadoc for giving your package its own documentation.
It was introduced in Javadoc 5.0, and replaces package.html
.
Upvotes: 35
Reputation: 4259
package-info.java file contains package level documentation as well as annotations.
Upvotes: 10