Error: JAVA_HOME is not defined correctly. We cannot execute /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java

Error :
Error: JAVA_HOME is not defined correctly. We cannot execute /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java

JAVA_HOME env variable was not installed added using below commands in terminal :

added JAVA_HOME in my .bash profile ( nano ~/.bash_profile.sh ) as below
export JAVA_HOME=”$(/usr/libexec/java_home)”
export PATH=$JAVA_HOME/jre/bin:$PATH

Oops though i have provide the JAVA_HOME its not visible to my maven i got error like :

Terminal – > mvn –version failed with error :
Error: JAVA_HOME is not defined correctly.
We cannot execute /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java

Now after googling i come across below link
https://stackoverflow.com/questions/27026169/maven-ignoring-java-home-on-osx/36701610#36701610

which says to add the java_home in ~/.mavenrc
I don’t know what is ~/.mavenrc file is about but after adding
export JAVA_HOME=”$(/usr/libexec/java_home)” to ~/.mavenrc maven worked fine.

Soon i will write about what is ~/.mavenrc and its relation with maven variables.

Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *