Getting Your Hands Dirty

Home

Learning Clojure requires you to install Clojure. Luckily, contrary to common belief, Clojure compiler is as simple as a single file.

Let’s see how we setup a running environment for Linux or macos.

You need Java

You will need Java runtime. I use Java 8 (in 2018) with my Clojure installation. You only need the JRE.

$ sudo apt-get install openjdk-8-jre

Download Clojure compiler

The Clojure compiler comes as a single .jar file. How convenient.

Here is the URL. Just download clojure-1.8.0.jar (~3.5M)

https://repo1.maven.org/maven2/org/clojure/clojure/1.8.0/

Write Clojure and run

$ echo '(println "hello world")' > hello.clj
$ java -jar clojure-1.8.0.jar hello.clj

REPL

$ java -jar clojure-1.8.0.jar
Clojure 1.8.0
user =>

A little program

; a.clj
(let [name "Jack"]
  (println "Greetings" name))

Let’s run it:

$ java -jar clojure-1.8.0.jar a.clj

Ken Pu
Thursday, Apr 5, 2018

comments powered by Disqus