# Maven 项目执行的时候提示 JAVA\_HOME is not correctly set 错误

**URL:** <https://www.isharkfly.com/t/maven-java-home-is-not-correctly-set/13679>\
**Category:** 程序语言\
**Tags:** java\
**Created:** [August 12, 2021, 3:14am UTC](https://www.isharkfly.com/t/maven-java-home-is-not-correctly-set/13679 "2021-08-12T03:14:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [August 12, 2021, 3:14am UTC](https://www.isharkfly.com/t/maven-java-home-is-not-correctly-set/13679/1 "2021-08-12T03:14:44Z")

</div>

提示的错误信息如下：

```auto
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (attach-javadocs) on project codebank: MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

```

如下图：

![2021-08-11_23-14-09](https://www.isharkfly.com/images/transparent.png)

## 问题和解决

上面的提示已经比较清楚了。

你没有在你的环境变量中设置 JAVA\_HOME

![2021-08-11_23-18-33](https://www.isharkfly.com/images/transparent.png)

需要按照上面的设置一个环境变量。

如果你使用的是 IEDA 的话，你需要重启的 IDEA 环境。

如果你使用的是命令行工具的话，你也需要退出后重启。

然后再次进行编译，应该就能解决上面的问题了。
