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.
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026