These are instructions to get started with Clojure using IntelliJ IDEA, La Clojure and Leiningen for people that don’t know any of those tools. They are for Mac OS X but they may be adaptable to other operating systems as well.

It doesn’t expect you to know Clojure or IntelliJ IDEA. I think this might be a good way for beginners to get started (instead of Emacs for example). I been using RubyMine for quite a while and I’m happy with it. The only requirement in installing Homebrew on your mac, which you should anyway if you want to code.

Install Clojure and Leiningen using Homebrew:

brew install clojure
brew install leiningen

Download IntelliJ IDEA and install it:

Run it:

Open the preferences (⌘,) and go to the plugins section:

Download and install La Clojure plugin:

Download and install the Leiningen plugin.

 

Restart IntelliJ IDEA:

 

Create a Leiningen project:

lein new foobar
 Created new project in: /Users/pupeno/Temporary/foobar

Open the project in IntelliJ IDEA:

 

Now open Project Structure (⌘;) and go to SDK. If you tried to run the Clojure REPL and got the error “No jdk for module ‘foobar’”, this is what you need to do to fix it:

Click on the plus sign and add a JSDK:

The default is just fine:

And you should see something like:

Go to the project

and select the newly created 1.6 SDK:

Go to modules

open dependencies:

and add a single entry:

Use the installed Clojure from /usr/local/Cellar/clojure/1.2.1/clojure.jar:

I’m not totally sure about that step. It might be that the IntelliJ project you are creating works only on a machine where Clojure is located on the same path.

As they say… works for me! Restart IntelliJ… not sure if you’ll need to, but I needed it.

Open the project if it wasn’t open and start the Clojure REPL (⇧⌘F10), it’s in the Tools menu:

It works:

Open a file:

Type a little program, like:

(defn hello-world []
  (println "Hello world"))

Load the file on the REPL (⇧⌘L), which is in Tools → Clojure REPL:

Enjoy magnificent code completion:

and run the code:

And that’s it. Whether IntelliJ IDEA and La Clojure is a viable developing environment only time will tell.


7 responses to “Getting started with La Clojure on Mac OS X, a visual guide”

  1. Ian Phillips Avatar

    Great write up! And I didn’t know about the Leiningen plugin, so thanks for pointing that out.

    One suggestion: when adding the Clojure jar a better way of going it is to add 2 libraries using the “Attach Jar Directories…” button, one library for lib and one for lib/dev, then you can just stick with using “lein deps” to manage the project dependencies and IDEA will pick them up automatically.

    1. Pablo Avatar

      Yes, attaching the lib directory of the project as a jar directory is definitely the way to go.

  2. Ismail Avatar

    Hi,

    Some of the images are not showing up anymore. Would appreciate it if you could take a look into it.

  3. sandover (@sandover) Avatar

    Please do fix the images — they are essential to the content! Thanks.

  4. anderskristian Avatar

    Good stary on getting started on Clojure. Homebrew was the most difficult to pass for me. IntelliJ stuff just worked..

  5. Steve Frog Avatar

    I’ve found that using La Clojure plugin with IntelliJ 12 causes it to use 100% CPU constantly, thereby rendering it not very useful.

Leave a Reply

You may also like:

Hi, I'm Pablo, this is my web site. You can follow me or connect with me:

Or get new content delivered directly to your inbox.

Join 4,044 other subscribers

I'm writing a book

Stack of copies of How to Hire and Manage Remote Teams

How to Hire and Manage Remote Teams, where I distill all the techniques I've been using to build and manage distributed teams for the past 10 years.

I write about:

announcement blogging book book review book reviews books building Sano Business C# Clojure ClojureScript Common Lisp database Debian Esperanto Git ham radio history idea Java Keep on Posting Kubuntu Lisp Non-Fiction OpenID programming Python Radio Society of Great Britain Rails rant re-frame release Ruby Ruby on Rails Sano science science fiction security self-help Star Trek startups technology Ubuntu web WordPress

I've been writing for a while:

%d bloggers like this: