Last Updated: February 25, 2016
·
1.158K
· splattael

How to install clojure including startup script

I will use stow to install clojure.jar and custom script in /usr/local

Download clojure

Download clojure ZIP from http://clojure.org/downloads and unpack it.

Prepare stow directory

As root do

mkdir -p /usr/local/stow/clojure/bin
mkdir -p /usr/local/stow/clojure/lib
# prepare startup script
touch /usr/local/stow/clojure/bin/clj
chmod a+x /usr/local/stow/clojure/bin/clj

Copy jar and create startup script

Copy clojure-1.5.1.jar from unpacked clojure ZIP to /usr/local/stow/clojure/lib.
Make sure that JAR is world readable.

In /usr/local/stow/clojure/bin paste into clj

#!/bin/bash

JAR=/usr/local/lib/clojure-1.5.1.jar
exec java -cp $JAR clojure.main "$@"

Stow

cd /usr/local/stow
stow -v clojure

Use startup script

As REPL just run clj:

$ clj 
Clojure 1.5.1
user=> 

To execute a clojure script file just pass it to clj as argument:

clj hello.clj

Have fun!