ref – https://www.delftstack.com/howto/java/change-java-version-mac/
To see what version of Java you have installed:
/usr/libexec/java_home -V
1.8.45.14 (x86_64) “Oracle Corporation” – “Java” /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_45 (x86_64) “Oracle Corporation” – “Java SE 8” /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
In my case, when I decided to install an older version of JDK (jdk-8u45-macosx-x64), it installed at
java -version (note one dash)
java version “1.8.0_45”
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
So I’m using 1.8.0
Sometimes, it installs in other locations: