Getting up and running with Clojure in Windows

The recommended way to get Clojure installed is through Leiningen, this can be a bit frustrating in Windows since the installer is out of date, so here’s what you have to do to get started:

  1. Run the installer (make sure your JDK is up to date). If you try “lein repl” in a command line it will give you an error.
  2. Grab the latest lein.bat file.
  3. Update the LEIN_VERSION in the bat file to what you want to get. The default should be fine, but you can check here for a list of the latest releases.
  4. Drop the bat file into “C:\Users\<YourUserName>\.lein\bin” or wherever you installed Leiningen. Replace the old file.
  5. In the command line run “lein self-install” it should pull the standalone jar file.
  6. Now if you type “lein repl” into your command line the Clojure REPL should start up. And you’re good to go.

The next thing you should do is figure out which editor or IDE to use. There are solid Clojure plugins for Eclipse and IntelliJ but I found myself overwhelmed with tons of Java features that I wasn’t going to use. There are syntax highlighting plugins for Sublime and Atom but I wanted something a little bit more helpful and IDE-like so I settled on LightTable. LightTable’s really easy to get going with and it has good documentation, but if you really just want to jump into things, the least you need to do is:

  1. Create a new project with Leiningen: “lein new myproject” (make sure you’re in the directory you want to be in).
  2. Then in LightTable go to View -> Connections -> Add Connection -> Clojure. And then navigate to the project.clj file you just created with lein.
  3. After the project connects, you can open up the generated core.clj file and play around the instarepl, and that should be enough to get you started.

     

 

 

Advertisements