JAVA_HOME not set Java Origin: Application & API Last updated 12 Oct 2026

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Build tools (Gradle, Maven, Android tools) can’t find a JDK.

Exact message you may see JAVA_HOME is not setJAVA_HOME is set to an invalid directory'java' is not recognized
Seen on: Java

Meaning

Tools look for JAVA_HOME or java on PATH. Fresh machines, CI images and shells started without your profile lack it.

Common causes

  • No JDK installed
  • JAVA_HOME not exported
  • JAVA_HOME pointing to a JRE or removed JDK
  • Windows: JAVA_HOME set to the bin folder

⚡ Quick fix

  1. Install a JDK (Temurin)
  2. Export JAVA_HOME to the JDK root (not bin)
  3. Restart the terminal/IDE

Detailed fix by platform

Linux

  1. export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))

How to diagnose

  1. Installed — java -version
  2. Variable — echo $JAVA_HOME

🔧 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: Application & API. Errors that are often confused with or caused by this one (click to open):

adb server version doesn't match — adb server version (41) doesn't match this client (39); killing... (Android)adb server version do…author identity unknown — Author identity unknown *** Please tell me who you are. (Git)author identity unkno…aws: error: argument — aws: error: argument command: Invalid choice / Unknown options (AWS)aws: error: argumentcommand not found — bash: command not found (Linux)command not foundDefault FirebaseApp is not initialized — IllegalStateException: Default FirebaseApp is not initialized in this process (Android)Default FirebaseApp i…docker-compose: command not found — docker-compose: command not found / 'compose' is not a docker command (Docker)docker-compose: comma…ENOENT — npm ERR! enoent ENOENT: no such file or directory, open '/path/package.json' (npm)ENOENTInconsistent JVM-target compatibility — Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (17) and 'compileDebugKotlin' (1.8) (Android)Inconsistent JVM-targ…JAVA_HOME…

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.