JAVA_HOME is not defined correctly [How to Solve]

It’s a magic question. The system was running, and suddenly it hung up. Various Java packages are missing

1. Check maven configuration.bash_ profile

2. Check the run call file. Mavenrc 2

Run Java – version, no problem, normal

Run MVN – version, oh

Error: JAVA_HOME is not defined correctly.
  We cannot execute Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/java

And then you start to flip through the configuration file

##### Explain the two jdk versions 7 and 8 on your machine, this command determines your Java version
echo $JAVA_HOME
##### is normally 8
Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home

##### check if maven is missing also normal
which mvn
/Users/****/Documents/maven/apache-maven-3.3.9/bin/mvn

##### started checking the configuration files and they were fine
vim ~/.bash_profile

Checked PATH=$PATH:$MAVEN_HOME/bin and it's not missing (maven configuration at the end of the article)

I started to feel depressed, so I checked another file called by Maven runtime

##### into the root home
cd $HOME

##### Find the file
ls -a

##### No .mavenrc found

##### depressed 。。。。

##### hit directly
vim .mavenrc

##### and type in
JAVA_HOME=$(/usr/libexec/java_home)

##### save
ESC ---- :wq! 

##### Check
mvn -version

##### normal
Apache Maven 3.3.9

Error: JAVA_HOME is not defined correctly. We cannot execute Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/bin/java

Similar Posts: