Installing Clojure and Leiningen
Before writing any Clojure code, you need a working toolchain: a Java Development Kit (JDK) since Clojure runs on the JVM, the official Clojure CLI tools for running programs and managing dependencies via deps.edn, and often Leiningen, the long-standing build tool that scaffolds projects and manages builds through a project.clj file. Setting these up correctly the first time avoids most beginner frustration.
Cricket analogy: Setting up a Clojure development environment is like a fast bowler assembling match-day kit before a Test — you need the right boots (the JDK) as your base foundation, spikes correctly fitted (the Clojure CLI), and a properly weighted match ball (Leiningen for project management) before you can even walk out to bowl the first over.
Installing the Java Development Kit (JDK)
Clojure requires a JDK, typically version 11 or newer, since Clojure source compiles to JVM bytecode. Before installing any Clojure-specific tooling, check whether a compatible JDK is already present by running java -version in a terminal; if it's missing or too old, install one via a package manager like Homebrew on macOS, apt on Ubuntu, or an installer such as Eclipse Temurin.
Cricket analogy: Clojure needs a JDK the way a batter needs a properly certified bat — checking java -version before installing Clojure is like an umpire checking a bat's dimensions with a bat gauge before the toss, since an incompatible or missing JDK will get your setup rejected before play even starts.
Installing Clojure CLI Tools
The official Clojure CLI tools, invoked as clj or clojure, provide the simplest way to run Clojure code, start a REPL, and resolve dependencies declared in a deps.edn file. On macOS you can install them with Homebrew (brew install clojure/tools/clojure); on Linux, a shell installer script is provided on clojure.org; typing clj at the terminal drops you straight into an interactive REPL.
Cricket analogy: The Clojure CLI tools, invoked with clj or clojure, are like a captain calling for a specific field placement before a delivery — typing clj at the terminal immediately puts you into a live REPL, and deps.edn acts as the pre-agreed fielding chart declaring where every fielder (dependency) stands for the whole innings.
Installing and Using Leiningen
Leiningen is Clojure's original, still widely used build tool. It scaffolds new projects with lein new app my-app, generating a conventional folder structure (src, test) and a project.clj file that declares dependencies and build configuration, and it runs a project's main function with lein run. Installing it is typically a single package-manager command or downloading the lein shell script directly.
Cricket analogy: Running lein new app my-app to scaffold a project is like the ICC handing a newly promoted Associate nation a standardized ground layout — pitch dimensions, boundary rope distance, and sightscreen placement are all set up automatically to a known standard, the way Leiningen generates a conventional folder structure instantly.
# Check Java is installed (JDK 11+ recommended)
java -version
# Install Clojure CLI tools (macOS via Homebrew)
brew install clojure/tools/clojure
# Verify the Clojure CLI
clj -e "(+ 1 2 3)"
;; => 6
# Install Leiningen (macOS via Homebrew)
brew install leiningen
# Scaffold a new Leiningen project
lein new app my-first-app
cd my-first-app
# Run it
lein runThe Clojure CLI tools (clj/clojure) and deps.edn are the officially maintained, minimal way to run Clojure and manage dependencies, while Leiningen predates them and adds project scaffolding, plugins, and build tasks via project.clj. Many teams use both: Leiningen for full project builds and clj for quick REPL experiments.
- Clojure requires a Java Development Kit (JDK), typically version 11 or newer, since it runs on the JVM.
- Verify your JDK installation with
java -versionbefore installing any Clojure tooling. - The official Clojure CLI tools (
clj/clojure) use adeps.ednfile to declare and resolve dependencies. - Leiningen is a popular build tool that uses a
project.cljfile and offers project scaffolding vialein new. lein new app <name>generates a conventional project structure with src, test, and configuration files.lein runbuilds and executes a Leiningen project's main entry point.- Many Clojure developers use both the CLI tools and Leiningen depending on the task at hand.
Practice what you learned
1. What must be installed before Clojure can run, since Clojure targets the JVM?
2. Which file does the official Clojure CLI tools use to declare dependencies?
3. What command scaffolds a new Leiningen application project?
4. Which file does Leiningen use to configure a project's dependencies and build settings?
5. What is a quick way to verify your Clojure CLI installation works?
Was this page helpful?
You May Also Like
What Is Clojure?
An introduction to Clojure — a modern, functional Lisp dialect that runs on the JVM and emphasizes immutability and simplicity.
Clojure Syntax Basics
A tour of Clojure's core syntax: s-expressions, literal data types, the four collection types, and how to define values and functions.
The REPL and Forms
How Clojure's Read-Eval-Print Loop works, how forms are evaluated, and why REPL-driven development is central to the Clojure workflow.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics