Purpose of the JAVA_HOME, M2, and M2_HOME variables
java, maven, path
Solution
`JAVA_HOME` should refer to directory where Java that you want to use is installed. This variable is often used by various scripts, so it is recommended to define it. `JAVA_HOME` itself should not be added to `PATH`. You should add `JAVA_HOME/bin` to be able to run commands from this directory without specifying the concrete path.
`M2_HOME` is a home of Maven. It is used by script `mvn` (or `mvn.bat` on Windows).
Problem
What do I need the `JAVA_HOME`, `M2`, and `M2_HOME` environment variables for if the paths that should go there are already appended to my PATH variable?