# 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:

• note that the path list is a windows path list (with backslashes and semi-colons), so it can be hard to specify in a shell script
• the REPL doesn’t work (enter key doesn’t evaluate lines)

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

#!/usr/bin/sh

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.

## Classpath

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 REPL

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