Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven is unable to find javadoc command

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.

like image 910
amone Avatar asked Mar 25 '18 05:03

amone


People also ask

How do I fix javadoc errors?

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).

What is javadoc in Maven?

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.

What is the javadoc command?

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.

How do I disable javadoc in Maven?

The Javadoc generation can be skipped by setting the property maven. javadoc. skip to true [1], i.e.


1 Answers

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>
like image 91
miskender Avatar answered Sep 18 '22 14:09

miskender