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
- Install a JDK (Temurin)
- Export JAVA_HOME to the JDK root (not bin)
- Restart the terminal/IDE
Detailed fix by platform
Linux
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
How to diagnose
- Installed — java -version
- 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:
Similar errors
Most viewed in Java
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Did this fix work for you?
Report a correction or suggest an improvement
Last updated 12 Oct 2026