Diagnose Java setup failures that block Clojure: wrong JDK selection, missing javac, stale PATH entries, bad JAVA_HOME, editor mismatch, dependency download problems, and permission errors.
Most Java setup failures are selection problems, not mysterious JVM behavior. The wrong Java executable wins on PATH, JAVA_HOME points to an old install, the editor uses a different SDK, or the Clojure CLI cannot reach Maven repositories.
Start by reducing the problem to a terminal command. Then add the editor, build tool, and REPL back one at a time.
| Symptom | Likely cause | First check |
|---|---|---|
java not found |
JDK not installed or not on PATH |
which java / where java |
javac not found |
JRE-only install or JDK bin missing |
javac -version |
| Java version is unexpected | Multiple JDKs installed | command location and JAVA_HOME |
| Terminal works, editor REPL fails | Editor uses different JDK or working directory | REPL (System/getProperty "java.home") |
| Dependency downloads fail | Proxy, certificate, network, or repository issue | Maven/Clojure tool error text |
| Works locally, fails in CI | CI Java setup differs | CI Java version and setup action/image |
Do not change five things at once. Make one change, open a new terminal or restart the affected tool, then verify again.
When multiple JDKs exist, the first executable on PATH usually wins. Check both the version and location:
1java -version
2which java
On Windows:
1java -version
2where java
If the wrong JDK appears, fix the selection mechanism your team uses: package manager, version manager, system environment variables, shell profile, IDE project SDK, or CI setup. Avoid patching one terminal window with temporary commands and calling the environment fixed.
javacIf java works but javac fails, you probably have either:
bin directory is not on PATHInstall or select a full JDK, then verify both commands:
1java -version
2javac -version
JAVA_HOMEJAVA_HOME should point to the JDK root. It should not point to bin, java, javac, or a project directory.
| Bad value | Why it fails |
|---|---|
/path/to/jdk/bin |
Tools may append bin/java, producing a broken path |
/path/to/jdk/bin/java |
Points to an executable, not the JDK root |
| Old removed JDK | Tools fail even if java on PATH works |
Different version than java -version |
Maven, Gradle, Clojure CLI, and editor may disagree |
After changing JAVA_HOME, restart the terminal or tool that launches Clojure.
If the terminal is correct but the editor-connected REPL is wrong, inspect the running JVM from Clojure:
1(System/getProperty "java.version")
2(System/getProperty "java.home")
Then adjust the editor’s project JDK, REPL launch command, or environment inheritance. This is a common source of false Clojure errors because the code is running, just not on the JVM you thought.
If Java works but Clojure dependencies fail, stop reinstalling Java and read the dependency error.
Common causes include:
The Clojure CLI has flags and commands for classpath and dependency diagnosis; use those when the failure is clearly in dependency resolution rather than Java discovery.
When helping another developer, ask for these exact outputs:
1java -version
2javac -version
Then ask for the command location and the REPL Java properties if the editor is involved. Those four facts usually narrow the problem faster than a screen share of installer dialogs.