I'm trying to run the maven verify
command but getting this error.
MavenReportException: Error while generating Javadoc: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.
Maven cannot find the javadoc
command so it cannot create the documentation.
The interesting part is that I can run the mvn javadoc:jar
command and it successfully works. Besides my JAVA_HOME
is points to the correct location.
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
This is from the pom file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>attach-javadoc</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
Please don't tell me this is the duplicate of the question Unable to find javadoc command - maven. I know the problem is the same but our situations are different and my JAVA_HOME
points to the right location. So that solution doesn't work for me.
You need to call mvn javadoc:fix to fix main Java source files (i.e. inside src/main/java directory) or mvn javadoc:test-fix to fix test Java source files (i.e. inside src/test/java directory).
javadoc:javadoc generates the Javadoc files for the project. It executes the standard Javadoc tool and supports the parameters used by the tool. javadoc:test-javadoc generates the test Javadoc files for the project. It executes the standard Javadoc tool and supports the parameters used by the tool.
The javadoc command parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields.
The Javadoc generation can be skipped by setting the property maven. javadoc. skip to true [1], i.e.
I had this same issue with java 9.0.4 and macOs, and adding the following configuration in maven-javadoc-plugin
solved it for me
<configuration>
.....
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With