
On my machine I have the following version of Java. The command will print out something like the following depending on the available JDK in your computer. First you need to run /usr/libexec/java_home -V command to get the list of installed JDK. , users may use Macports(pkg-mngr), etc.In this post you will learn how to set the default JAVA_HOME in Mac OS X when you have more than one JDK installed in your computer. You can see all installed Java versions with: /usr/libexec/java_home -VĪnd avoiding brew/Homebrew(pkg-mngr) based solution would be better choice 1, 2, 3, 4, 5, 6. If you're using Java 14, then change version number in above command, into -version 14.0
before running a java based App, either setup the JAVA_HOME env var globally (see this), or Use a shell-script: to select a specific Java version/folder before starting a specific java-based App.
From that point-on, that java should work fine. & again specify a privileged user access+Password, to allow macOS "Open"/run it.
In Terminal, run: $($(/usr/libexec/java_home -version 12.0)/bin/java -version). & with a privileged user access+Password allow macOS to complete the move. Move the decompressed new jdk*.jdk folder into "/Library/Java/JavaVirtualMachines/" folder. Double-click on *.tar.gz to decompress it, & with a privileged user access+Password allow macOS to decompress it, (you will need allow decompress from here: "System Preferences" > "Security & Privacy" > under "General" tab > Goto bottomside section "Allow Apps Downloaded From" > press the "Allow" or "Open anyway" button). Download Java (JDK/SDK) version *.tar.gz file that you need for macOS from OpenJDK site into default "~/Downloads" folder, & verify its authenticity by comparing the OpenJDK site's shown SHA256 digest code, with the locally computed SHA256 digest code. Detail steps to solve such problem on macOSX Catalina (or macOS-XI/11/X1 Big-Sur) is shown here