A weblog by Will Fitzgerald

Setting up Clojure 1.2 for Mac OS X 10.6 (Snow Leopard)

These instructions are an amplification and some corrections (due to changes in standard Clojure distributions) on Mark Reid’s instructions, with a nod towards Ken Sipe). This will get you a Clojure 1.2 command line prompt.

First, create a directory for Clojure.

mkdir -p ~/Library/Clojure/lib

Second, download the core Clojure and Clojure contrib, and JLine packages.

mkdir -p ~/Library/Clojure/tmp
cd ~/Library/Clojure/tmp
wget --no-check-certificate https://github.com/downloads/clojure/clojure/clojure-1.2.0.zip
wget --no-check-certificate http://github.com/downloads/clojure/clojure-contrib/clojure-contrib-1.2.0.zip
wget http://downloads.sourceforge.net/jline/jline-0.9.95.zip

Third, unzip these, and put the jar files into the lib directory.

unzip clojure-1.2.0.zip
unzip clojure-contrib-1.2.0.zip
unzip jline-0.9.94.zip
cp clojure-1.2.0/clojure.jar ~/Library/Clojure/lib/clojure.jar
cp clojure-contrib-1.2.0/target/clojure-contrib-1.2.0.jar ~/Library/Clojure/lib/clojure-contrib.jar
cp jline-0.9.94/jline-0.9.94.jar ~/Library/Clojure/lib/jline.jar

If you like, you can delete the tmp directory created above.

Fourth, create a clj command and place it somewhere in an executable location.

It should look something like this (mostly like Ken Sipe’s command).

# Runs Clojure using the classpath specified in the `.clojure` file of the
# current directory.
# Will Fitzgerald 2011-01-18, based on:
# Ken Sipe 2010-02-20,
# Inspired by Mark Reid
# Sipe's code:
# http://kensipe.blogspot.com/2010/02/setting-up-clojure-110-on-mac-osx.html
# original: http://github.com/mreid/clojure-framework/blob/e1c80cc650f448713243be8272dba1fa3c1a7cea/clj
# This scripts expects java to be define.
# clojure.jar, clojure-contrib.jar, and jline.jar should be in
# ~/Library/Clojure/lib

# Add extra jars as specified by `.clojure` file
if [ -f .clojure ]
CP=$CP:`cat .clojure`

if [ -z "$1" ]; then
java -server -cp $CP \
jline.ConsoleRunner clojure.main
java -server -cp $CP clojure.main -i $*

You should now be able to execute clj or clj some.clj.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: