Detail steps to solve such problem on macOSX Catalina (or macOS-XI/11/X1 Big-Sur) is shown here https://apple.stackexchange.com/a/396025/133434
• 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 shown SHA256 digest code with the locally computed SHA256 digest code.
• 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).
• Move decompressed
jdk*.jdk folder into
& with a privileged user access+Password allow macOS to complete the move.
• In Terminal, run:
$($(/usr/libexec/java_home --version 12.0)/bin/java -version)
& again specify a privileged user access+Password, to allow macOS "Open"/run it.
• From that point-on, that
java should work fine.
• before running a java based App, either setup the JAVA_HOME env var globally, or Use a shell-script to setup a specific Java for a specific App.
if you're using Java 14, then change version number in above command, into
you can see all installed Java versions with: