Browse Learn Clojure Foundations as a Java Developer

Install Leiningen

Install Leiningen only when a project or learning path needs it, then verify lein, project.clj, REPL, test, and package commands without confusing it with the Clojure CLI.

Leiningen is a Clojure project automation tool. It manages dependencies, starts REPLs, runs tasks, creates projects, and packages applications. It is not obsolete just because the current official Clojure docs emphasize the Clojure CLI. Many real repositories still use Leiningen.

Install it when:

  • a project has project.clj
  • a tutorial or book explicitly uses lein
  • your team standardizes on Leiningen
  • you need a plugin/task workflow already built around it

Do not install it because every Clojure project must use it. New projects can also use the Clojure CLI and deps.edn.

Installation Approach

The Leiningen site recommends installing Leiningen through your package manager when possible. That is usually better than copying a random script from an old blog post.

Platform Practical route
macOS Homebrew or team-standard package manager
Linux Distribution package, Homebrew on Linux, or team-standard install
Windows Team-standard package manager or documented Windows setup
CI Explicit setup step or image with lein installed

After installation:

1lein --version
2lein help

If those commands fail, fix Leiningen discovery before debugging project dependencies.

What Leiningen Adds

Command Purpose
lein repl Start a REPL with the project classpath
lein test Run project tests
lein run Run the configured main namespace
lein uberjar Build a standalone jar when configured
lein help tutorial Read the built-in tutorial

For Java engineers, Leiningen will feel closer to Maven or Gradle than the Clojure CLI does because it exposes named tasks. The configuration is still Clojure data, and the runtime is still the JVM.

Verify Against A Project

In a project with project.clj, run:

1lein repl
2lein test

If the REPL starts but tests fail, Leiningen is installed; now debug the project. If lein itself is not found, debug installation or PATH.

Avoid Tool Confusion

Some machines have both clojure and lein. That is normal. The project decides which one matters.

Project file Start here
deps.edn Clojure CLI commands
project.clj Leiningen commands
both files Read the project README or CI config
neither file Look for Maven/Gradle or a custom script

Do not mix commands randomly. A REPL launched with clj may not have the same classpath as one launched with lein repl.

Knowledge Check

### When should you install Leiningen? - [x] When a project, team, or tutorial actually uses `lein` or `project.clj`. - [ ] Before every Clojure command, even in CLI-only projects. - [ ] Only to replace Java. - [ ] Only for editing Markdown. > **Explanation:** Leiningen is useful, but it is not required for every Clojure workflow. ### What does `lein repl` start? - [x] A REPL with the Leiningen project's classpath. - [ ] A Java compiler daemon only. - [ ] A browser. - [ ] A global Maven repository reset. > **Explanation:** `lein repl` starts an interactive Clojure session using the project configuration. ### Why should you avoid switching a Leiningen project to Clojure CLI immediately? - [x] Tool migrations can change classpaths, tasks, packaging, and CI behavior without improving the learning goal. - [ ] Leiningen projects cannot run tests. - [ ] Clojure CLI cannot run on the JVM. - [ ] `project.clj` is not source code. > **Explanation:** Learn the existing workflow first; migrate only when there is a concrete benefit.
Revised on Saturday, May 23, 2026