Fail to execute javadoc-plugin on Mac OSX (JAVA_HOME issue)

While building project with maven following error occurs:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.7:jar 
(attach-javadocs) on project api: MavenReportException: 
Error while creating archive:Unable to find javadoc command: 
The environment variable JAVA_HOME is not correctly set. -> [Help 1]

This happens, because JAVA_HOME points to JRE instead of JDK dir.
In my case it’s being set by the following command

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

and points to

/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home

Quick solution for this problem is adding the following inside properties tag :

<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>

Leave a Reply