Use Clojure with Cygwin

Setting up Clojure with cygwin looks pretty simple: download the jar, then use:

java -cp 'path\to\clojure.jar' clojure.main # works only with a few usages

to start a REPL or run a file.

Except that:

So I wrote a small shell script, named clj and put it in my path:


CP=`cygpath -wp '.:/Developer/clojure/clojure.jar:/Developer/clojure-contrib/clojure-contrib.jar'`

rlwrap java -cp "$CP" clojure.main "$@"

Cygpath -wp

The first thing to note in that script is that it uses a Unix path list, then converts it to a Windows path list with cygpath -wp. This makes it easier to write paths without worrying about double backslashes.


The classpath contains . and clojure-contrib.jar.

Adding . makes it possible to run Clojure scripts that include other clojure scripts.

Then adding clojure-contrib.jar enables to use some nice libs like clojure.contrib.monads.


The last thing is to fix the REPL. Here I use rlwrap, a GNU command wrapper that adds readline abbilities.

blog comments powered by Disqus