This is similar to a much older report of an error (https://intellij-support.jetbrains.com/hc/en-us/community/posts/206880855-MavenReportException-Error-while-creating-archive-Unable-to-find-javadoc-command-The-environment-variable-JAVA-HOME-is-not-correctly-set-), but I would like to find the proper way to address this in IntelliJ IDEA 2020.3.
When trying to build a project using Maven and generating javadocs with the javadoc:javadoc goal, the maven run is failing with
"Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.2.0:javadoc (default-cli) on project ContAnalysis: An error has occurred in Javadoc report generation: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set."
This happens when I launch IDEA from the GUI using the finder or other programs like LaunchBar. It does not happen if I launch IDEA from the command line. The build works perfectly if I run mvn from the command line.
I assume this means the JAVA_HOME variable is not set during the mvn run. Why is IDEA failing to pick this up properly?
The Build, Execution, Deployment > Build Tools > Maven > Runner setting is set to Use Project JDK, which points to a jdk containing a bin/javadoc command which can be run properly.
Adding the following to the below configuration does not solve the issue
Nor does setting the executable to an absolute path work. Something else must be wrong with the setting which IDEA is providing to mvn. Very puzzling.