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

**Code:** `JAVA_HOME not set` · **Category:** Java · **Seen on:** Java

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

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

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/java/java-home-not-set)
