javamavencheckstyle

Why is package-info.java useful?


When I run CheckStyle over my Java project it says Missing package-info.java file. for some classes, but not all of them. I can't really figure out why this message appears only sometimes. Furthermore my project runs perfectly fine without the package-info.java.

What does the package-info.java do? Do I really need it for my Java projects?


Solution

  • It is used to generate javadocs for a package.

    /**
    * Domain classes used to produce .....
    * <p>
    * These classes contain the ......
    * </p>
    *
    * @since 1.0
    * @author somebody
    * @version 1.0
    */
    package com.domain;
    

    Will generate package info for com.domain package:

    Example result: https://docs.oracle.com/javase/7/docs/api/java/awt/package-summary.html