Browse Learn Clojure Foundations as a Java Developer

Verify Java for Clojure

Run a compact Java verification checklist before installing or debugging Clojure so runtime, compiler, PATH, JAVA_HOME, classpath behavior, and editor configuration are aligned.

After Java is installed, verify it from the same places that will launch Clojure: terminal, editor, build scripts, and CI. Verification is not ceremonial. It prevents setup bugs from masquerading as Clojure bugs.

Minimal Verification Checklist

Run these first:

1java -version
2javac -version

Then verify command locations:

1which java
2which javac

On Windows, use:

1where java
2where javac

If the Clojure CLI is already installed, add:

1clj -h

clj -h is useful because the Clojure CLI fails early if it cannot find Java.

What Good Looks Like

Check Good result If it fails
java -version Supported Java runtime appears Install/select a JDK or fix PATH
javac -version Compiler appears and matches runtime major version Install full JDK or fix PATH
Command location Points to expected JDK manager or install path Remove stale Java entries or reorder PATH
JAVA_HOME Points to expected JDK root when used Update shell, system, or project settings
clj -h CLI help prints Fix Java discovery before debugging Clojure

This is also the point to document the result in the project README if the project requires a specific Java major version.

Verify The Editor Separately

Your terminal can be correct while your editor still launches a REPL with a different JDK. That happens when the editor has its own project SDK, starts from a GUI environment that does not load shell files, or uses an embedded terminal with different startup behavior.

Check the editor by starting the project REPL and evaluating:

1(System/getProperty "java.version")
2(System/getProperty "java.home")

Compare that output with the terminal. If they differ, fix the editor configuration before interpreting Clojure errors.

Verify Classpath Direction

Java installation verification is not only about versions. Clojure development depends on classpath construction. Later tools should be able to:

  • find Clojure source roots
  • find test roots
  • find resources/
  • download Maven dependencies
  • launch a REPL with the project classpath

If java works but dependencies fail to resolve, the Java runtime is probably not the problem. Check network/proxy/certificate settings, dependency coordinates, and the Clojure tool configuration.

A Small Java Smoke Test

When the machine is especially suspect, compile and run a tiny Java class:

1public class Smoke {
2  public static void main(String[] args) {
3    System.out.println(System.getProperty("java.version"));
4  }
5}

Then:

1javac Smoke.java
2java Smoke

This proves that the runtime and compiler can work together. Delete the generated files afterward; they are only setup diagnostics.

Knowledge Check

### Why evaluate `(System/getProperty "java.version")` in the editor REPL? - [x] It confirms which JVM the running Clojure REPL is actually using. - [ ] It installs a new JDK. - [ ] It prints the Clojure namespace path. - [ ] It compiles all Java files in the project. > **Explanation:** Editor REPLs may launch with a different JDK than your terminal. Inspecting the runtime property confirms the real process. ### What does `clj -h` prove after the Clojure CLI is installed? - [x] The CLI command can start far enough to find Java and print help. - [ ] All project tests pass. - [ ] Maven dependencies are already downloaded. - [ ] The editor is configured. > **Explanation:** `clj -h` is a fast Java-discovery check for the CLI, not a full project validation. ### If `java` works but Clojure dependencies will not download, where should you look next? - [x] Network, proxy, certificates, dependency coordinates, and tool configuration. - [ ] Only the Java language syntax. - [ ] The browser cache. - [ ] The project README font. > **Explanation:** A working JVM does not guarantee dependency resolution. Maven repository access and Clojure tool configuration are separate layers.
Revised on Saturday, May 23, 2026