I have 2 JAVA version on my Macbook. I want to change version from 14 to 11. I found 2 solutions on the internet but both are not working.
My java -version result is
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+14)
OpenJDK 64-Bit Server VM (build 14.0.1+14, mixed mode, sharing)
1st Solution (How to set or change the default Java (JDK) version on OS X?), I run /usr/libexec/java_home -V then I got a result below,
Matching Java Virtual Machines (2):
14.0.1, x86_64: "OpenJDK 14.0.1" /Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home
11.0.8, x86_64: "Java SE 11.0.8" /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home
Then I did
export JAVA_HOME=`/usr/libexec/java_home -v 11.0.8`
After checking from java -version, The result is still 14.0.1
2nd solution (How to set JAVA_HOME in Mac permanently?), I edit ~/.bash_profile file as below,
export JAVA_HOME=`/usr/libexec/java_home -v 11.0.8`
And I run command
source ~/.bash_profile
echo $JAVA_HOME
It shows the result,
/Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home
But when I check the result with java -version, It's still 14.0.1 as well