Unable to find javadoc command - maven

You can make it use the java.home system property instead of the JAVA_HOME environment variable:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.0.1</version>
    <configuration>
        <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
    </configuration>
</plugin>

Source of idea: https://medium.com/@kankvish/fixing-issue-the-environment-variable-java-home-is-not-correctly-set-b5f0b66a84d0


A correct which java is not evidence enough, since /usr/bin/ will likely be in your PATH anyway. Check

$ echo $JAVA_HOME

for evidence. Or run

$ JAVA_HOME=/path/to/your/java/home mvn clean javadoc:jar package

On OS X you can set your JAVA_HOME via:

$ export JAVA_HOME=$(/usr/libexec/java_home)

which on my machine points to

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home