Browse Learn Clojure Foundations as a Java Developer

Start the Right Clojure REPL

Start standalone, project-connected, Leiningen, Clojure CLI, and editor-connected REPL sessions, and choose the mode that matches the code and classpath you need.

Starting a REPL is easy. Starting the right REPL is the important habit. A standalone REPL is enough for language experiments. A project-connected REPL is what you need when code depends on project paths, dependencies, resources, tests, or editor integration.

Choose the Session Type

Need Start this
Try basic syntax or data transforms Standalone terminal REPL with clj
Work inside a deps.edn project Project REPL from the project root
Work inside a Leiningen project lein repl from the project root
Evaluate directly from editor buffers Editor-connected REPL
Run automation or scripts Usually clojure, not clj

The wrong REPL often looks like a Clojure problem, but it is usually a classpath problem.

Start a Standalone REPL

For terminal exploration:

1clj

You should see a prompt like:

1Clojure 1.12.5
2user=>

Use this when you do not need project code. It is ideal for small experiments:

1(require '[clojure.string :as str])
2(str/upper-case "repl")
3;; => "REPL"

Exit with Ctrl-D.

Start a deps.edn Project REPL

From a project root that has deps.edn:

1clj

That gives you the base project classpath from :paths and :deps. If your project defines aliases, start with the alias you need:

1clj -M:dev

or inspect the resulting classpath:

1clojure -Spath
2clojure -A:dev -Spath

For Java engineers, this is like asking: “Which source roots and dependencies are in this running JVM?”

Start a Leiningen Project REPL

From a directory with project.clj:

1lein repl

This starts a REPL with the Leiningen project classpath. Use this when the repository README or CI uses lein commands.

Do not mix project tools casually:

Project file Default REPL command
deps.edn clj or documented Clojure CLI alias
project.clj lein repl
Both Follow README and CI

Start an Editor-Connected REPL

Most serious Clojure work happens through an editor-connected REPL:

Editor Common entry point
IntelliJ IDEA + Cursive Run or connect a Clojure REPL configuration
VS Code + Calva Jack in or connect to a running REPL
Emacs + CIDER cider-jack-in or connect to nREPL

The exact UI changes over time, but the invariant is stable: the editor must connect to the same project classpath you would use from the terminal.

Verify the REPL Has the Right Project

After starting, verify with small checks:

1(System/getProperty "java.version")
2*ns*
3(require '[your-project.core :as core])

If a namespace cannot load, check:

Symptom Likely cause
Could not locate ... on classpath Wrong directory, wrong alias, or namespace/file mismatch
Dependency namespace cannot load Missing dependency or alias
Editor works but terminal fails Different command or classpath
Terminal works but editor fails Editor REPL not using project config

Key Takeaways

  • Use clj for quick terminal REPL work.
  • Use the project root and project tool when you need project code.
  • Use lein repl for Leiningen projects.
  • Use editor-connected REPLs for day-to-day development, but verify the classpath.
  • Most “REPL cannot find my code” problems are path, alias, or namespace problems.

Quiz: Start REPL

### When should you prefer a project-connected REPL? - [x] When you need project source paths, dependencies, resources, or tests - [ ] Only when arithmetic fails - [ ] Only after creating an uberjar - [ ] Never; standalone REPLs always load all projects > **Explanation:** Project-connected REPLs use the classpath and dependencies from the project. ### Which command is the usual starting point for a Leiningen project REPL? - [x] `lein repl` - [ ] `git repl` - [ ] `java -jar` - [ ] `clojure -T:build` > **Explanation:** `lein repl` starts a Leiningen-aware REPL from a project with `project.clj`. ### What should you check when a namespace cannot load? - [x] Current directory, aliases, classpath, and namespace-to-file mapping - [ ] Only CPU temperature - [ ] Only Git branch name - [ ] Only browser cache > **Explanation:** Namespace load failures are usually classpath or path-mapping problems.
Revised on Saturday, May 23, 2026