バージョンの確認方法
$ /usr/libexec/java_home
<$HOME>/Library/Java/JavaVirtualMachines/adopt-openjdk-1.8.0_265/Contents/Home
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
1.8.0_265, x86_64: "OpenJDK 8" <$HOME>/Library/Java/JavaVirtualMachines/adopt-openjdk-1.8.0_265/Contents/Home
1.8.0_161, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
<$HOME>/Library/Java/JavaVirtualMachines/adopt-openjdk-1.8.0_265/Contents/Home
バージョンの変更方法
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_161`
$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_265`
$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)