How to Use Clojure on Ubuntu 16.04

What is Clojure

Clojure is a dialect of Lisp programming language running on Java Virtual Machine (JVM) and Common Language Runtime.

Clojure treats code as data, it also have macro system. Currently the development process is community-driven overseen by Rich Hicket as BDFL.

Clojure used by companies like Puppet, Walmart and Funding Circle.

In this tutorial we’ll learn how to use Clojure on Ubuntu 16.04 Xenial Xerus.

Requirements

This tutorial assumes you already have Java Development Kit installed. You can follow install Java 8 on Ubuntu 16.04 tutorial if you have no java installed yet.

Downloading Clojure

Clojure distributed as .jar file. You can visit Clojure download page to get the latest stable version of Clojure.

At the time of this version, the latest stable version of Clojure is version 1.8.0.

Download clojure using wget


$ wget -c https://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/clojure-1.8.0.zip

Extract downloaded file using unzip. If you have no unzip installed yet you can install it using command below


$ sudo apt-get install unzip

Extract downloaded Clojure archive using command below


$ unzip clojure-1.8.0.zip

This will create new directory called clojure-1.8.0. Go to that directory and let’s run Clojure REPL


$ cd clojure-1.8.0
$ java -cp clojure-1.8.0.jar clojure.main
Clojure 1.8.0

Let’s create hello world from Clojure REPL.


user=> (prn "Hello Clojure From HowtoDojo!")
"Hello Clojure From HowtoDojo!"
nil

Summary

In this tutorial we already learned how to download and run Clojure REPL on Ubuntu 16.04. Have fun with Cloujure!