Setting up a Clojure development environment proved to be quite a challenge, especially given my handicap of using Windows.
The most widely used editor for Clojure is Emacs. I don't have any idea how to use it, but I have seen video of people who know what they are doing, and I really want that!
There are lots of options for setting up Clojure. If you are just starting out, there are too many. There are at least half a dozen editors that have Clojure plug-ins. Emacs itself has two. The instructions available also tend to present different ways of accomplishing the same thing.
I am not going to give you lots of options. I am going to give you the steps to go from a clean Windows 7 install to having the most popular plug-in for the most popular editor using the most popular build tool for Clojure. I am sure there is a lot of value to all of the flexibility that other people support, but it is lost on me and if you are reading this, it is probably lost on you too.
Also, I intend to cover each step in excruciating detail. I know from experience that any instructions on this subject, no matter how detailed, would include at least one or two steps that assumed I actually knew how to use Emacs. If you follow these instructions and there is a step that is not completely clear to you, please put it in the comments so that I can fix it. If the detail is too much for you, just read the bold print!
Our goal is to have a working installation of the Leiningen build tool, and the SLIME plug-in for the Emacs editor.
Before I start, let me say this works best if you do not already have clojure installed on your computer, or more specifically that you do not have the clojure.jar file in your class path. The Leiningen install will fail if you do.
Install the Java Development Kit (JDK )
Version 1.6 or better is required, I am running 1.7 Standard Edition. Download this from Oracle. There is also a link to installation instructions on that page.
After jdk is installed you need to make sure that the environment variables are set up correctly. (Control Panel >> System and Security >> System >> Advanced system settings >> Environment Variables...)
Under user variables I have JAVA_HOME with a path to the folder where the jdk is installed. On my system this is C:\Program Files\Java\jdk1.7.0_01
Under System Variables, the java bin directory needs to be in your path. click edit on the path, so you can scroll through and look to see if these settings are already there, and if not add them (path items are separated with ; on windows) %Java_Home%\bin\ and the physical path to the bin directory that holds the jdk executable. In my case this is C:\Program Files\Java\jdk1.7.0_01\bin\
Test the java installation by going to a command prompt (click the windows button in your taskbar and type cmd in the search box) at the command prompt type:
if the computer responds with a version number the jdk is set up properly, if it says that javac is not found, you have a problem you need to fix before you move on.
Install Leiningen(build tool)
Create a folder that will hold the leiningen batch file and also a helper utility it needs. Mine is in c:\lein. to create it I went to the command prompt, typed
After that type exit to close that command prompt window. Add the path to your new folder to your path setting.
Download curl from
and place curl.exe and into your new folder.
download libssl from
and place libeay32.dll and ssleay32.dll into your new folder.
Download the lein.bat file from
and put it in to your new folder. (My browser displayed the text, so to save it I did file >> save page as and then navigated to my c:\lein folder.
Open a new command prompt and type
After the installation completes you can test your leiningen install by typing
at the command prompt. It should launch the clojure repl which you can test by typing
(+ 1 2)
at the user prompt.
click the x in the upper right to close the command prompt.
Download emacs from
extract the emacs-23.1 folder, and put it somewhere. I just put mine in c:\
Create a folder to hold plugins for emacs named .emacs.d I put mine in my emacs-23.1 folder.
Create a new user environment variable called HOME in the value put the path to the .emacs.d folder. in my case this is C:\emacs-23.1
Add the path to the emacs.exe folder to your path. mine was C:\emacs-23.1\bin
Install Clojure modeCreate a file called init.el in your .emacs.d folder and enter this text
(add-to-list 'load-path "~/.emacs.d/")
Add the file clojure-mode.el from
to your .emacs.d directory. I found the easiest way to do this was to copy the text in the code window at that url and paste it into a new text file that I called clojure-mode.el. If you just download the webpage, you will get lots of html commands that will cause errors in emacs.
Install Swank pluginopen a new command prompt and type
lein plugin install swank-clojure 1.3.4
-- note initially this install got hung for me, when I disabled avg link scanner it worked right away.
Create a new Clojure project
from the command prompt, navigate to a folder where you would like to create clojure files.
from c:\Users\Rick I typed
cd projects create the new project by typing
lein new testproj
after emacs loads type
emacs will spend a couple of moments processing the plugin. After this, you should have a running REPL that you can test the same way that you tested the repl from leiningen. type
(+ 1 2).
If you get 3, it works.