Unable to locate a Java Runtime macOS Origin: Platform & cloud Last updated 5 Nov 2026

macOS: The operation couldn't be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java

macOS has no JDK installed (or the installed one isn't registered), so the java stub fails.

Exact message you may see Unable to locate a Java RuntimeThe operation couldn't be completed. Unable to locate a Java RuntimeNo Java runtime present, requesting installUnable to locate a Java Runtime. Please visit http://www.java.com for information on installing JavaJAVA_HOME is not set and no 'java' command could be found macOS
Seen on: macOS Java

Meaning

Install a JDK (brew install openjdk@21 or Temurin) and link it: sudo ln -sfn $(brew --prefix openjdk@21)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-21.jdk. Set JAVA_HOME with /usr/libexec/java_home -v 21. /usr/bin/java is only a stub that finds JDKs under /Library/Java/JavaVirtualMachines.

Common causes

  • No JDK installed
  • Homebrew OpenJDK not symlinked into JavaVirtualMachines
  • JAVA_HOME pointing to a removed JDK
  • Wrong architecture JDK
  • PATH missing brew openjdk

⚡ Quick fix

  1. brew install --cask temurin or brew install openjdk@21 + the symlink
  2. export JAVA_HOME=$(/usr/libexec/java_home -v 21)
  3. Verify: java -version

Detailed fix by platform

macOS

  1. /usr/libexec/java_home -V lists registered JDKs

How to diagnose

  1. JDK — Installed?
  2. Registered — java_home lists it?
  3. JAVA_HOME — Valid?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

Homebrew Cask: It seems there is already an App at — Homebrew: Error: It seems there is already an App at '/Applications/Chrome.app' (macOS)Homebrew Cask: It see…Homebrew: No available formula with the name — Homebrew: Error: No available formula with the name "x". Did you mean ...? (macOS)Homebrew: No availabl…Homebrew: Permission denied @ dir_s_mkdir — Homebrew: Error: Permission denied @ dir_s_mkdir - /usr/local/Cellar / /opt/homebrew is not writable (macOS)Homebrew: Permission …JAVA_HOME not set — ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. (Java)JAVA_HOME not setYour Command Line Tools are too outdated — Homebrew: Error: Your Command Line Tools (CLT) are too outdated. Update them from Software Update / Please update to the latest macOS (macOS)Your Command Line Too…zsh: bad CPU type in executable — macOS (Apple Silicon): zsh: bad CPU type in executable: ./tool (macOS)zsh: bad CPU type in …zsh: command not found: brew — macOS: zsh: command not found: brew (Homebrew not on PATH on Apple Silicon) (macOS)zsh: command not foun…Unable to…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.