javadoc can’t find package on command line

Tags: ,



I have this sample code and I’m trying to produce the javadoc for it. From the same directory where my package test is defined (see code below) I’m executing javadoc test on the command line and I get:

Loading source files for package test...
javadoc: error - No source files for package test
1 error

The extent of the code is in Docs.java, shown here:

package test;

/**
 * this is some text
 */
class Docs {

    public static void main(String[] args) {
        System.out.println("I'm in a package!");
    }
}

Here is the Java version info:

bash-3.2$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)

I haven’t found a clear answer online why javadoc can’t find the package. Any help appreciated! (edited per requests)

Answer

You must be at the same level of the “test” package directory. So “javadoc test” should work. If the “test” package is at /tmp/test, you should execute from /tmp



Source: stackoverflow