Clojure on Windows 7

The installation of Clojure on Windows is quite an accomplishement in itself. The following steps are those I finally isolated from multiple forums, blogs and painful discoveries. It’s mostly a note for myself.

Leiningen Grab the last stable version of Leiningen’s .bat file. If you don’t have Wget installed on your machine, install it or put the binary (wget.exe) in the same folder as lein.bat. In this directory, open the command window and type lein self-install. This will install leiningen-1.x.x-standalone.jar on your machine. It will probably be in your user directory, depending of your configurations.

Environment variables and the PATH

Copy the path to your new lein.bat. Then type <win><pause> (windows key and the key to the right of screen lock). Now go in Advanced system setting, Environment Variables. Find the PATH variable and click edit. Now type a semicolon and paste the path to your lein.bat file. This will make sure you can call Leiningen from anywhere in your command line with the simple “lein”. You should try it now, just to make sure everything is ok.

At this point you have a working installation of Clojure. But surely you want more, don’t you?

Emacs (SLIME)

Assuming you want to use Clojure in its most natural environment, you should use Emacs (yay!).

Install clojure-mode from git or Marmalade.


Update 2012-03-07 mer.: Be sure to restart Emacs if you changed the environment variables in the previous step!


Swank Clojure is a server that allows SLIME (the Superior Lisp Interaction Mode for Emacs) to connect to Clojure projects.

To install Swank-clojure, open once again the command line and type

lein plugin install swank-clojure 1.4.0

(Where 1.4.0 is the version you want to install).

If isn’t blocked, (which it is, at my office, God only knows why…) you should see the plugin being downloaded and installed. That’s it.

No, really, that’s it!

Beginners’ traps

Before you try jack-in, you should make a project as described in Leiningen instructions. The most important part before trying anything else is to have a .clj ready. You must have this file opened in Emacs before you do the magic M-x clojure-jack-in!!

If you get an error message complaining about “$SHELL”, type M-x customize-variable RET clojure-swank-command RET and enter “lein jack-in %s” instead of the current value.

3 responses to “Clojure on Windows 7

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: