Search code examples
javamacos

switch java version on mac OS


Im trying to switch the java version with the following

export JAVA_HOME='/usr/libexec/java_home -v 1.8.0_172'

but when I run java -version I got the following

java version "10.0.1" 2018-04-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

I want to switch to the 1.8.0_172 version in MAC how it can be done ?


Solution

  • Assuming you have jdk1.8.0.172 installed, one option is:

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home