I did my due diligence and researched. I followed the following steps:
/usr/libexec/java_home -V
result was:
Matching Java Virtual Machines (2):
11.0.13 (x86_64) "Oracle Corporation" - "Java SE 11.0.13" /Library/Java/JavaVirtualMachines/jdk-11.0.13.jdk/Contents/Home
1.8.0_372 (x86_64) "Homebrew" - "OpenJDK 8" /usr/local/Cellar/openjdk@8/1.8.0+372/libexec/openjdk.jdk/Contents/Home
export JAVA_HOME=
/usr/libexec/java_home -v 1.8.0_372
echo $JAVA_HOME
result was:
/usr/local/Cellar/openjdk@8/1.8.0+372/libexec/openjdk.jdk/Contents/Home
But when I do java -version, the following result shows up:
java version "11.0.13" 2021-10-19 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.13+10-LTS-370) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.13+10-LTS-370, mixed mode)
Result shows default java is still Java 11. I want to switch it to use Java 1.8
Can anyone help me on this?