Search code examples
javamacosjava-home

Wrongly set the JAVA_HOME in mac


I changed the Java home of my mac from Java 10 to Java 8 by using the below comment:

echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.8)" >> ~/.bash_profile

But unfortunately, when I wun the command I put 1.7 instead of 1.8:

echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile

Now when I am opening the terminal getting the below error: Unable to find any JVMs matching version "1.7".


Solution

  • Open you .bash_profile file with your favorite text editor and look at the last line. It should be

    export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
    

    Change the 1.7 to 1.8 and you should be OK.