JAVA_HOME not set ☕ Java

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

  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 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.