6

When I try to create my project's Javadoc in IntelliJ IDEA using Maven, the following error appears:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.1:javadoc (default-cli) on project spotify-web-api-java: An error has occurred in Javadoc report generation: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]

JAVA_HOME is correctly set in any console window I open though, as echo $JAVA_HOME confirms. Why isn't it in IntelliJ?

dargmuesli
  • 541
  • 1
  • 5
  • 9
  • I suppose this behavior is explained by [this](https://stackoverflow.com/questions/13961615/unable-to-find-javadoc-command-maven#comment100306963_54323506) comment. – Olivier Cailloux Aug 27 '19 at 06:58

1 Answers1

7

This is because IntelliJ's internal consoles use their own environment. You can set variables for Maven in the settings dialog under Build, Execution, Deployment > Build Tools > Maven > Runner > Environment variables. Add JAVA_HOME with whatever echo $JAVA_HOME returns in your usual terminal window as a value and Maven will be able to find the javadoc command!

dargmuesli
  • 541
  • 1
  • 5
  • 9