How to install Java on Macbook
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
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 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.
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.