[MNG-8156] mvn shell script should print the environment variables when “The JAVA_HOME environment variable is not defined correctly”
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Didier Loiseau](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=didier%20loiseau)** opened **[MNG-8156](https://issues.apache.org/jira/browse/MNG-8156?redirect=false)** and commented
When `$JAVA_HOME` is not properly set, it just prints:
```
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
```
and stops.
This is not very helpful as there is absolutely no indication of what is wrong exactly and how to fix it. For instance, in [this Stack Overflow question](https://stackoverflow.com/q/78614953/525036), the user had a correct `$JAVA_HOME`, but it was unknowingly overridden in their `.mavenrc`
The command should at least print the values of `$JAVA_HOME` and `$JAVACMD`, and ideally some additional help. Something like:
> JAVA_HOME: $JAVA_HOME
> JAVACMD: $JAVACMD
> If this is not what you expect, you should check the environment variables, the mavenrc file(s), and ensure that you have execution rights on the java executable.
> You can try setting environment variable MAVEN_SKIP_RC=true to bypass mavenrc temporarily.
---
**Affects:** 3.9.7
Contributor guide
Assessment
This issue has not been assessed yet.