Wednesday, 22 June 2011

Programming Clojure

So, I'm going to take a look at programming Clojure, with some help from the book "Programming Clojure" by Stuart Halloway, published by the Pragmatic Programmers.

To get Clojure running, I've downloaded, which is the core stuff, and, which is a library of extra modules.  There's no installation process necessary - I've just unzipped these into folders in c:\Program Files (I'm on Windows 7).

Now I've created a folder c:\Users\Phancock\Documents\Clojure, where I will be putting my own code.

So finally I need a batch file that will invoke the Clojure interpreter.  This sets up the classpath to the Clojure libraries and calls Java with the namespace clojure.main, and passes the name of the script you want to run and any parameters.  So my script looks like this:-

@echo off
set CLOJURE=c:/Program Files/clojure-1.2.0/clojure.jar
set CONTRIB=c:/Program Files/clojure-contrib-1.2.0/target/clojure-contrib-1.2.0.jar
set DEV=c:/Users/phancock/Documents/Clojure
java -cp "%CLOJURE%;%CONTRIB%;%DEV%" clojure.main %*

No comments:

Post a Comment