Assuming you use bash shell and installed Java with the Oracle installer, you could add the following to your
.bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/jre/bin:$PATH
This would pick the correct JAVA_HOME
as defined by the Oracle installer and will set it first in your $PATH
making sure it is found.
Also, you don’t need to change it later when updating Java.
From:https://stackoverflow.com/questions/27319495/error-java-home-is-not-defined-correctly-executing-maven
Read More:
- [Solved] Mac Maven Command Error: zsh: command not found
- Maven (http://repo1.maven.org/maven2/): Failed to transfer file and PKIX path building failed: sun.secu
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.1.1:analyze-only
- [Solved] MVN Build Project Error: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test
- MVN compile Error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin…
- [Solved] Error installing MVN: Java_Home is set to an invalid directory
- Maven error: Could not find artifact jdk.tools [How to Solve]
- [Solved] Error:Maven Resources Compiler: Maven project configuration required for module ‘XX‘ isn‘t available
- [Solved] O2oa compile error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- [Solved] Spring Boot Package Error: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0
- IDEA Create maven project error: Error running‘[org.apache.maven.pluginsmaven-archetype-pluginRELEASE
- IDEA Maven Fail to Download Dependencies Error: ERROR – #org.jetbrains.idea.maven – Cannot reconnect.
- [Solved] SpringBoot Pack Project: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources
- [Solved] Maven Publish Error: Failed to execute goal org.apache.maven.pluginsmaven-deploy-plugin2.8.2deploy
- [Solved] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on
- [Solved] IDEA Add maven Project Error: Error:(3,21)java: Package javax.servletdoes not exist
- [Solved] IDEA Maven Error: Cannot resolve xxx & Maven Dependencies Error
- [Solved] org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject…
- [Solved] Maven Project Error: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
- [Solved] Error:maven-resources-production:ruoyi-ywjs: java.lang.NegativeArraySizeException