How to install Clojure

Want the best way to learn Clojure?

Invest in yourself with my Beginner Clojure Signature Course.

  • 8 fundamental modules
  • 240 fun lessons
  • 42 hours of video
Beginner Clojure: An Eric Normand Signature Course

Let's get Clojure installed on your system. This guide will help you through the following steps to get Clojure installed.

  • Start a terminal

    Open a terminal for issuing commands.

    Start a terminal
  • Install Java Development Kit (JDK)

    The Java Virtual Machine (JVM) and related development tools

    Install Java Development Kit (JDK)
  • Install Leiningen

    Clojure's most popular project tool

    Install Leiningen
  • Install Clojure Command Line Interface (CLI)

    The official way to run Clojure.

    Install Clojure Command Line Interface (CLI)

The instructions depend on what operating system you are running. Please click your operating system below.

Click your operating system

Start a terminal

For these instructions, you will need to have a terminal, or command line, open. This is a text-based interface to issue commands 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.

The prompt (where you will type your commands) 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 (version 21) for new installs.

Java

1. Verify if Java is installed

In your terminal, run the following command:

java -version

It may say something like "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:

$ java -version
java version "1.10.1"
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
$

This output indicates java version "1.10.1". In the Java world, we ignore the "1." at the beginning. So that's called Java 10. If you have Java less than 11, you need to upgrade. If you have Java 11 or higher, you are good for the courses here, but you may want to upgrade to the latest LTS version (version 21).

2. Install or upgrade Java

We need to download the latest JDK.

Visit adoptium.net.

Click the big "Latest LTS Release" button. Make a note of the version number.

This will download a pkg file. Open that file to begin installing it.

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 the latest release of OpenJDK.

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

Leiningen is a project tool for Clojure. Many Clojure projects are still built using Leiningen. Some projects here 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.

Clojure

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. Some of the projects here use the Clojure CLI.

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 run a new prompt (called a REPL), like this:

$ clj
Clojure 1.11.1
user=>

If you've got that, then you're ready to roll! Hit Ctrl-c to exit the Clojure REPL.

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.

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 (version 21) for new installs.

Java

1. Verify if Java is installed

In your terminal, run the following command:

java -version

It may say something like "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, like this:

$ java -version
java version "1.10.1"
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
$

This output indicates java version "1.10.1". In the Java world, we ignore the "1." at the beginning. So that's called Java 10. If you have Java less than 11, you need to upgrade. If you have Java 11 or higher, you are good for the courses here, but you may want to upgrade to the latest LTS version (version 21).

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 the latest version of OpenJDK.

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

Leiningen is a project tool for Clojure. Many Clojure projects are built using Leiningen. Some Clojure projects here 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.

Clojure

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. Some of the projects here still use Leiningen, but some use the CLI.

1. Install dependencies

sudo apt-get install -y bash curl rlwrap

2. Download the install script

curl -L -O https://github.com/clojure/brew-install/releases/latest/download/linux-install.sh

3. Add execute permissions to install script

chmod +x linux-install.sh

4. Execute the installer

sudo ./linux-install.sh

5. Verifying the installation

Now that it's all installed run the following to test it out:

clj

It should run a new prompt (called a REPL), like this:

$ clj
Clojure 1.11.1
user=>

If you've got that, then you're ready to roll! Hit Ctrl-c to exit the Clojure REPL.

Start a terminal

You need a terminal, or command line, open for these instructions. A terminal is a text-based interface to talk to your computer. You can open it by searching for "command prompt" in the search bar and 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.

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 Enter 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.

Java

I recommend installing Java Development Kit (JDK) version 21 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, like this:

> java -version
java version "1.10.1"
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
>

This output indicates java version "1.10.1". In the Java world, we ignore the "1." at the beginning. So that's called Java 10. If you have Java less than 11, you need to upgrade. If you have Java 11 or higher, you are good for the courses here, but you may want to upgrade to the latest LTS version (version 21).

2. Install or upgrade Java

We need to download the latest version of the JDK.

Visit adoptium.net.

Click the "Latest LTS Release" button. Make a note of the version.

This will download a .msi file (installer). Open that file to begin installing it. A window should open. 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 you noted above.

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

Leiningen is a project tool for Clojure. Many Clojure projects are built using Leiningen. Some projects here use Leiningen and some use the CLI.

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!

Clojure Command Line Interface (CLI)

The official way to run Clojure.

There are three steps to installing the Clojure CLI on your Windows machine.

Clojure

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 projects here still use Leiningen. It is a good idea to install it.

1. Verify/install Scroop

Scoop is an installer for the Windows command line. Many programmers use it to install development tools.

We can install the Clojure CLI using Scoop. Open a PowerShell terminal and type the following command to verify it is installed.

scoop search clojure

If the command is not found, you need to install Scoop. Continue with this installation step. If it does work, skip to the next step.

To install Scoop, run the following:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Optional: Needed to run a remote script the first time
irm get.scoop.sh | iex

This command will run a script and will guide you through the process if it needs any input.

2. Installing Clojure CLI and its dependencies

Now that you have Scoop ready execute the following at your command prompt:

Install git

If you don't have git installed, you will need it to add the Clojure package.

scoop install git

You need some things from the "extras" package.

scoop bucket add extras

We need to add the Clojure package from a GitHub repo.

scoop bucket add scoop-clojure https://github.com/littleli/scoop-clojure

Finally install the Clojure CLI.

scoop install clj-deps

3. Verifying the installation

Now that it's all installed, run the following to test it out:

clj

It should run a new prompt (called a REPL), like this:

> clj
Clojure 1.11.1
user=>

If you've got that, then you're ready to roll! Hit Ctrl-c to exit the Clojure REPL.

Want the best way to learn Clojure?

Invest in yourself with my Beginner Clojure Signature Course.

  • 8 fundamental modules
  • 240 fun lessons
  • 42 hours of video
Beginner Clojure: An Eric Normand Signature Course