amone
amone

Reputation: 3862

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.

Upvotes: 14

Views: 16649

Answers (2)

miskender
miskender

Reputation: 7938

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>

Upvotes: 17

Oleksii Kyslytsyn
Oleksii Kyslytsyn

Reputation: 2426

For JDK versions 1.8, 9, 11, 12, 14, 15, 16, 17:

<build>
    <plugins>
        <!-- ... -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <!--<version>3.2.0</version>-->
            <configuration>
                <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                <!--<doclint>none</doclint>-->
            </configuration>
        </plugin>
        <!-- ... -->
    </plugins>
</build>

Upvotes: 12

Related Questions