OpenJDK Java (includes JRE) is open-source, & it is FREE for any Commercial & any deployment/distribution & any Personal usage.
Oracle Java (JDK) (includes JRE) has OpenJDK & closed-source/proprietary components, & it is free only-for Personal usage, a paid License required for any Commercial usage & for any deployment/distribution, & all users also must do a (free) web-registration to download any binary/source. You may see this too.
- in macOS-X Catalina (or macOS-XI/11/X1 after it), obtain the
"openjdk*.tar.gz"
archive-file (not dmg/zip) from OpenJDK.Java.net
or its archive-page, (make sure you see "https" (or Locked-Lock-symbol) in web-browser when you download) . Then verify/compare downloaded file's authenticity/integrity : you may use hash/digest SHA256 code shown on openjdk site, Use openssl
tool in Terminal utility : with such command: openssl sha256
& then drag the openjdk*.tar.gz
file from Finder into that openssl
command-line in Terminal, press enter to compute hash/digest, then Compare computed SHA256
digest-code with sha256
what is shown on https://OpenJDK.Java.net/
secure webpage, both must match/same,
- double-click on
"openjdk*.tar.gz"
(to decompress it) in Finder , MacOS may show notice & stop that,
- Open your
"System-Preferences"
> "Security & Privacy"
> under "General"
tab > goto bottomside section "Allow Apps Downloaded From"
> press the "Allow" or "Open anyway"
button there to allow the decompression of "openjdk*.tar.gz"
archive-file (macOS will ask to enter Password of a privileged Admin type account), then it should decompress , if it does not decompress then again double tap on the "openjdk*.tar.gz"
file in Finder, & choose "Open"
/"Allow" button if macOS asks you again , then it will finally decompress that "*.tar.gz"
file, & extract a folder from it,
- copy that newly extracted/decompressed OpenJDK folder
"jdk*.jdk"
, & goto below destination folder & MOVE (to move use the "alt/option" button to change the "paste" mode into "move" mode) the "jdk*.jdk"
folder inside below destination location:
"/Library/Java/JavaVirtualMachines/"
macOS will ask again to enter a privileged accnt Password, do that to complete the move.
- open Terminal , run this command:
/usr/libexec/java_home
if output contains+shows : "/Library/Java/JavaVirtualMachines/jdk-*.jdk/Contents/Home"
, where *
will actually show the Java version number, then its good.
- in Terminal, run this long command-set:
echo '#!/bin/bash' > ~/TestJava.sh ; echo "export JAVA_HOME=\"\$(/usr/libexec/java_home --version 14.0)\";" >> ~/TestJava.sh ; echo "export PATH=\"\$JAVA_HOME/bin:\$PATH\";" >> ~/TestJava.sh ; echo "java -version ;" >> ~/TestJava.sh ; chmod +x ~/TestJava.sh ; ~/TestJava.sh
if you want to avoid above long command-set, then run below shorter command:
$($(/usr/libexec/java_home --version 14.0)/bin/java -version)
macOS will ask you to enter a privileged accnt + Password again, do that, & choose "Open"
/"Allow", then you should see output like this:
openjdk 14.0.1 2020-04-14
OpenJDK Runtime Environment (build 14.0.1+7)
OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
(at the time of writing this answer i used openjdk 14.0.1, so above output shows those . if you're using Java 13, & if you want to use long command-set shown above then run this nano
command after that: nano ~/TestJava.sh
, & change the line which has version number 14.0
, into 13.0
, if you want to use a shorter command which is also shown in above, then (also for this) just change the 14.0
into 13.0
)
- Done . From this point-on, you will-not/should-not see any-other blocks/locks from macOS for using/running that
java
.
OPTIONAL STEP : if you want-to & need-to, then before running a java-based App, either setup the JAVA_HOME
env var globally (to apply same Java on all java-based apps), or Use a shell-script to setup a specific Java to run a specific java-based App . A sample of such shell script is already shown in above long command-set , suit/change/modify that to your needs . if you want-to then follow this(goto bottom-side "Optional : Java ENV VAR" section) or this(recommended) or this or any other better instructions.
OPTIONAL STEP : you can see all installed Java versions with: /usr/libexec/java_home -V
(you should see your installed version on the displayed list)