In 2022, you can use just brew
brew install openjdk
and maybe you need to update PATH env:
export PATH="/usr/local/opt/openjdk/bin:$PATH"
…and for the future give a try to sdkman, is better than brew
curl -s "https://get.sdkman.io" | bash
then open a new shell and try list to see what you could install ;-)
sdk list java
At time of writing you could use:
sdk install java 17.0.1-tem
Answer from freedev on Stack Overflowmacos - How to install Java on a Mac - Stack Overflow
macos - How to brew install java? - Stack Overflow
How do I install java for Mac
Java Dev switching to Mac for the first time
Videos
In 2022, you can use just brew
brew install openjdk
and maybe you need to update PATH env:
export PATH="/usr/local/opt/openjdk/bin:$PATH"
…and for the future give a try to sdkman, is better than brew
curl -s "https://get.sdkman.io" | bash
then open a new shell and try list to see what you could install ;-)
sdk list java
At time of writing you could use:
sdk install java 17.0.1-tem
I have been doing some research on how to install Java jre and jdk on correct PATH.
JRE has been discontinued since Java 11. Since you are talking about Java 14, there is no JRE for it. You just need to install (and configure, if required) JDK.
Use the following command and then check java -version:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home"
export PATH="$PATH:$JAVA_HOME/bin"
Note that it will work only for your current session i.e. java -version won't work in another terminal window.
To set JAVA_HOME permanently, do as follows:
vi .bash_profile
Write the following line into .bash_profile file, save and quit:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home"
export PATH="$PATH:$JAVA_HOME/bin"
Then refresh (read and execute .bash_profile)
$ source .bash_profile
And finally test
$ echo $JAVA_HOME
$ java -version
Note: Also, This thread may be useful to you.
Turns out java has been moved into brew core recently, so the correct command as of August 2022 is:
brew install java
Then check your installation by running
java -version
If the result does not looks like this:
openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment Homebrew (build 18.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.2+0, mixed mode, sharing)
but like this:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
Then you also need to create a symlink for the system Java wrappers to find this JDK:
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk.jdk
As an add-on to the accepted answer: to install a certain version of Java, e.g. version 11, run:
brew install openjdk@11
And symlink it:
sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk-11.jdk
I tested this answer using a clean install of High Sierra 10.13.6. All updates from Apple were installed.
The downloads of the JDKs can be found at Java Downloads. I could not correctly view this site using Safari under High Sierra. Instead, I installed and used Firefox ESR (Extend Support Release). This link for Firefox download can be successfull viewed from Safari. The file I downloaded and installed was Firefox 115.16.1esr.dmg.
I tried JDK 23 by downloading and installing jdk-23_macos-x64_bin.dmg. This was not recognized by Java. Next, I tried JDK 21 by downloading and installing jdk-21_macos-x64_bin.dmg. This was recognized by Java.
Instructions for uninstalling a JDK can be found here. Personally, I just used the Finder to move the /Library/Java/JavaVirtualMachines/jdk-23.jdk folder to the Trash.
I tested by using the simple code given below. The code was stored in the file named Simple.java.
class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
Example of testing is given below.
dmas-Mac:Desktop dma$ javac Simple.java
dmas-Mac:Desktop dma$ java Simple
Hello Java
BTW, I tested JDK 23 using macOS Monterey and did not encounter the problems that occurred with High Sierra.
I've successfully installed Java 21 from Microsoft on High Sierra.
$ java --version
openjdk 21.0.8 2025-07-15 LTS
OpenJDK Runtime Environment Microsoft-11933195 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Microsoft-11933195 (build 21.0.8+9-LTS, mixed mode, sharing)
Java 25 has the some issue as mentioned above. It looks like the jdks have been build with a dependency to "chkstk_darwin" which ist not available in High Sierra.
I install java x64 DMG installer for Mac. I installed the on my Mac and when I go check it in terminal it tells me that no such file or directory is found my Mac? I want to use Java to create Minecraft mods.