How to install Clojure

From OO to Clojure Workshop!
Watch my free workshop to help you learn Clojure faster and shift your paradigm to functional.
Let's get Clojure installed on your system. This guide will help you install the following software.
Java Development Kit (JDK)
The Java Virtual Machine (JVM) and related development tools
Leiningen
Clojure's most popular project tool
Clojure Command Line Interface (CLI)
The official way to run Clojure. (optional, and not yet available for Windows)
The instructions depend on what operating system you are running. Please click your operating system below.
Click your operating system
macOS
This guide will help you install the following software on your Mac.
Start a terminal
For these instructions, you will need to have a terminal, or command line, open.
This is a text-based interface to talk to your computer, and you can open it by
running Terminal.app, which is found under /Applications/Utilities
. If you
have never used the terminal before, you may want to spend some time reading up
on command-line basics.
When you open it, it will look something like this:
The prompt (where you will type your commands) may look different: it usually shows the computer name and user name, as well as the folder or directory you are currently in.
I will tell you to run commands in your terminal. When I say that, I mean "type the command into the terminal and press the Return key."
Java Development Kit (JDK)
There are three steps to installing Java on your Mac.
Java 11 is the minimum requirement.
I recommend installing the latest Java Development Kit (JDK) LTS version for new installs.
1. Verify if Java is installed
In your terminal, run the following command:
java -version
It may say something like "-bash: java: command not found
". In that case, Java
is not installed on your system, and we will need to install it. If it prompts
you to install Java, ignore it and cancel anything it opens.
It may output a few lines saying what Java version is installed, like this:
This output indicates java version "1.7.8_45"
. In the Java world, we ignore
the "1." at the beginning. So that's called Java 7. If you have Java less than
11, you will want to upgrade. If you have Java 11, you are done with the Java
step. Move on :)
2. Install or upgrade Java
We need to download the latest JDK.
Visit adoptium.net. It should look something like this:
Click the big "Latest LTS Release" button.
This will download a pkg file. Open that file to begin installing it. A window should open, like this:
Proceed through the steps of the installer. You may "trash" the pkg when you're done.
3. Verify Java again
Open a new Terminal window.
Run the following command:
java -version
It should indicate you have OpenJDK version 17 or higher.
You're done with Java!
Leiningen
Leiningen is Clojure's most popular project tool.
There are four steps to installing Leiningen on your Mac.

Leiningen is a project tool for Clojure. Most Clojure projects are still built using Leiningen. The projects at PurelyFunctional.tv all use Leiningen.
Leiningen is a command-line tool you run using the lein
command. We will need
to install the lein
command to your path, which means it will be available to
you to run whatever directory you are in.
To install lein
, execute the following commands in your terminal. You will be
prompted to enter your computer's login password. If you are having trouble
calling sudo
with the message "User is not in sudoers file, incident
reported", follow these
instructions to give
your account sudo
permissions.
1. Download the lein
script
curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein
2. Move the lein
script to the user programs directory
sudo mv lein /usr/local/bin/lein
3. Add execute permissions to the lein
script
sudo chmod a+x /usr/local/bin/lein
4. Verify your installation
You should have Leiningen installed now. Run the following command to test it out.
lein version
It should take a while to run, as it will download some resources it needs the first time. If it completes successfully, you are golden!
Clojure Command Line Interface (CLI)
The official way to run Clojure.
There are three steps to installing the Clojure CLI on your Mac.
The Clojure Command-Line Interface (CLI) is a relatively new (2018) addition to the Clojure tooling world. It is the official way to run Clojure applications. Many people are using it now instead of Leiningen. However, Leiningen is still very popular, and many of the courses here on ericnormand.me still use Leiningen. It is a good idea to install it.
1. Verify/install Homebrew
Homebrew is a package manager for macOS. It is a common tool for developers to use on Macs.
The Clojure CLI is installed using Homebrew. Type the following command to update the Homebrew package repository and verify it is installed.
brew update
If it looks like it ran, you're good to move on to the next step. If the system
complains that the brew command is not found
, then you will need to install
Homebrew. To do that, execute the following command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This command will run a script that explains what it will do and wait for you to confirm it.
2. Installing Clojure CLI
Now that you have Homebrew ready, execute the following:
brew install clojure/tools/clojure
This will install the Clojure CLI.
To upgrade from a previous install:
brew upgrade clojure/tools/clojure
3. Verifying the installation
Now that it's all installed, run the following to test it out:
clj
It should start a REPL, which looks like this:
If you've got that, then you're ready to roll!
Linux
This guide will help you install the following software on your Linux machine.

Start a terminal
You will need to have a terminal, or command line, open. This is a text-based
interface to talk to your computer. In Ubuntu, you can open it by clicking "Dash
Home" and typing Terminal
. You can also open a terminal anytime by
pressing CTRL-ALT-T
. If you have never used the terminal before, you may want
to spend some time reading up on command-line
basics.
It should look something like this:
The prompt (where you will type your commands) may look different: it usually shows the computer name and user name, as well as the folder or directory you are currently in.
I will tell you to run commands in your terminal. When I say that, I mean "type the command into the terminal and press the Return key."
If you're using Ubuntu or another version of Linux, open your terminal. The commands we type will be the same.
Java Development Kit (JDK)
There are three steps to installing Java on your Mac.
Java 11 is the minimum requirement.
I recommend installing the latest Java Development Kit (JDK) LTS version for new installs.
1. Verify if Java is installed
In your terminal, run the following command:
java -version
It may say something like "-bash: java: command not found
", or it may suggest
a package to install. Ignore it. In either case, Java is not installed on your
system, and we will need to install it.
It may output a few lines saying what Java version is installed. The first line will indicate the version of Java.
If the version starts with a "1.", then you should drop the "1." and read the number immediately after that. So if it's "1.7.8_45", you should drop the "1." and read that as "Java 7".
It may not have the "1.". For instance, it may say "java version 10.45". In that case, that's Java 10.
We need Java 11, so if the number is less than 11, we need to upgrade. If you have Java 11 or higher, you can move on to installing Leiningen. :)
2. Install or upgrade Java
We have some commands to run in the terminal. These instructions are for Ubuntu and Debian. If you run another distribution of Linux, follow the instructions here.
1. Allow extra repositories and install packages you need
sudo apt-get install -y software-properties-common wget apt-transport-https
2. Get the Eclipse Adoptium GPG Key (for encryption)
sudo mkdir -p /etc/apt/keyrings
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/apt/keyrings/adoptium.asc
3. Add the AdoptOpenJDK repository
echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
4. Update the repository index
sudo apt-get update
5. Install Adoptium Temurin
sudo apt-get install -y temurin-17-jdk
3. Verify Java again
Run the following command in the terminal.
java -version
It should indicate you have OpenJDK version 17 or higher.
You're done with Java!
Leiningen
Leiningen is Clojure's most popular project tool.
There are five steps to installing Leiningen on your Linux machine.

Leiningen is a project tool for Clojure. Most Clojure projects are still built using Leiningen. The Clojure projects in my courses all use Leiningen.
Leiningen is a command-line tool that you run with the lein
command. We will
need to install the lein
command to your path, which means it will be
available to you to run whatever directory you are in.
To install lein
, execute the following commands in your terminal. You will be
prompted to enter your computer account's password.
1. Install curl
command
sudo apt-get install -y curl
2. Download the lein
script
curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > lein
3. Move the lein
script to the user programs directory
sudo mv lein /usr/local/bin/lein
4. Add execute permissions to the lein
script
sudo chmod a+x /usr/local/bin/lein
5. Verify your installation
You should be installed now. Run the following command to test it out.
lein version
It should take a while to run, as it will download some resources it needs the first time. If it completes successfully, you are golden!
Clojure Command Line Interface (CLI)
The official way to run Clojure.
There are five steps to installing the Clojure CLI on your Linux machine.
The Clojure Command-Line Interface (CLI) is a relatively new (2018) addition to the Clojure tooling world. It is the official way to run Clojure applications. Many people are using it now instead of Leiningen. However, Leiningen is still very popular, and all of the courses here still use Leiningen. You won't need the CLI for the courses here, but installing it is a good idea.
1. Install dependencies
sudo apt-get install -y bash curl rlwrap
2. Download the install script
curl -O https://download.clojure.org/install/linux-install-1.10.2.774.sh
3. Add execute permissions to install script
chmod +x linux-install-1.10.2.774.sh
4. Execute the installer
sudo ./linux-install-1.10.2.774.sh
5. Verifying the installation
Now that it's all installed, run the following to test it out:
clj
It should start a REPL, which looks like this:
If you've got that, then you're ready to roll!
Windows
This guide will help you install the following software on your Windows machine.
Start a terminal
For these instructions, you will need to have a terminal, or command line, open. This is a text-based interface to talk to your computer. In Windows 10, you can open it by searching for "command prompt" in the search bar then clicking on the Command Prompt app.
If you have never used the terminal before, you may want to spend some time reading up on command-line basics.
It should look something like this:
The prompt (where you will type your commands) may look different: it usually shows the folder you are currently in.
I will tell you to run commands in your terminal. When I say that, I mean "type the command into the terminal and press the Return key."
Java Development Kit (JDK)
There are three steps to installing Java on your Windows machine.
Java 11 is the minimum requirement.
I recommend installing the latest Java Development Kit (JDK) LTS version for new installs.
I recommend installing Java Development Kit (JDK) version 11 or newer for new installs.
1. Verify if Java is installed
In your terminal, run the following command:
java -version
It may say something like "'java' is not a recognized command'
". If it does, that means Java is not installed and
we will need to install it.
It may output a few lines saying what Java version is installed. The first line will indicate the version of Java.
If the version starts with a "1.", then you should drop the "1." and read the number immediately after that. So if it's "1.7.8_45", you should drop the "1." and read that as "Java 7".
It may not have the "1.". For instance, it may say "java version 10.45". In that case, that's Java 10.
We need Java 11, so if the number is less than 11, we need to upgrade. If you have Java 11 or higher, you can move on to installing Leiningen. :)
2. Install or upgrade Java
We need to download JDK 11 or above.
Visit adoptium.net. It should look something like this:
Click the "Latest LTS Release" button.
This will download a .msi
file (installer). Open that file to begin installing
it. A window should open like this:
Proceed through the installer with the defaults.
3. Verify Java again
Open a new command prompt, then run the following command:
java -version
It should indicate you have OpenJDK version 11 or higher.
You're done with Java!
Leiningen
Leiningen is Clojure's most popular project tool.
There are five steps to installing Leiningen on your Windows machine.

Leiningen is a project tool for Clojure. Most Clojure projects are still built using Leiningen. My courses all use Leiningen.
Leiningen is a command-line tool that you run with the lein
command. We need
to install the lein
command to your path so that you can run it in whatever
directory you are in.
To install lein
, execute the following commands in your
command prompt. You will be prompted to enter your password.
1. Download the lein.bat
script
curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein.bat
2. Create a bin
directory for scripts
md bin
3. Move the lein.bat
script to that directory
move lein.bat bin
4. Add bin
to your path
setx path "%path%;%USERPROFILE%\bin"
5. Complete your installation
Close the command prompt and open a new one. Then run the following command to finish the installation.
lein self-install
It should take a while to run, as it will download some resources it needs the first time. If it completes successfully, you are golden!