MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set.
Hi all,
When running a maven goal from IDEA (11 or 12) that includes javadoc creation I am getting the following error.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9:jar (attach-javadocs) on project locationmanager-service: MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]
The same POM will execute without issue using the same JDK (jdk1.7.0_09) from the command line. I am on Mac OS X 10.8.2 and at first I thought it was something to do with setting JAVA_HOME via the environment.plist file. I verified this is set correctly to the same JDK.
I don't recall having this issue with JDK 1.6 but I'd need to verify. Any ideas what is going wrong in IDEA here?
--
Matthew
请先登录再写评论。
I'm also experiencing the same problem.
Yes, I got that error too.
But I can build it successfully from the terminal.
Attachment(s):
Screen Shot 2012-12-07 at 下午5.35.27.png
Screen Shot 2012-12-07 at 下午5.35.00.png
I can't reproduce this problem. I've created a project with:
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
then ran 'package' goal, all works without any error.
Try to insert
<properties>
<aaa>${env.JAVA_HOME}</aaa>
<bbb>${java.home}</bbb>
</properties>
to pom.xml, does IDEA resolve these properties?
I'm having the same problem on my Mac when I use JDK 1.7.0_10.
I added this to my maven javadoc plugin configuration:
<javadocExecutable>${env.JAVA_HOME}/bin/javadoc</javadocExecutable>
The result:
The javadoc executable '${env.JAVA_HOME}/bin/javadoc' doesn't exist or is not a file
From this I conclude that env.JAVA_HOME is not defined.
Next I tried ${JAVA_HOME} without env. on front. Same result.
Next I tried java.home:
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
Result:
The javadoc executable '/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/jre/bin/javadoc' doesn't exist or is not a file.
From this I conclude that java.home points not to my JDK but to my JRE.
Next I tried stepping from java.home up one directory to the JDK:
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
This worked.
This is not ideal, of course. It works only if java.home points to a JRE inside a JDK.
I went with Dales solution, but put it in a profile:
<profile>
<id>intellij-javadoc-fix</id>
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
</configuration>
</plugin>
</plugins>
</build>
</profile>
and then I just check "intellij-javadoc-fix" in IntelliJ. This way it will only be used when run from within IntelliJ.
/Tommy
Hello Tommy,
you can also try running IDEA from the terminal: open -a /Applications/IntelliJ\ IDEA\ 12.app/ . If it works then your env variables for GUI apps are different from terminal ones. Try set them in /etc/launchd.conf http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x
Tommy's solution works,
I just added this configuration to maven plugin and ran command: mvn clean install
<javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>