How to Setup Clojure, Leiningen and LightTable setup on Windows

Clojure is a dynamic functional programming language which is designed to combine approachability and interactive development of a scripting language with an efficient and robust infrastructure for multi-threaded programming. Leiningen is a software used for automating Clojure projects. Basically, a easier way to use Clojure. And LightTable is a code editor which is one of the best editor for writing Clojure codes.

Setup Clojure, Leiningen and LightTable

Step 1: Install Java

  1. Download latest JDK from the Oracle Website.
  2. Install Java and find the location where it is installed. In most cases, it should be installed in the folder C:/Program Files/Java/JDK-[version]/bin/java.exe

Step 2: Create Required Environment Variables

Create a new User Environment Variable called "JAVA_HOME" and add the location of the JDK folder. Remember to not include the 'bin' folder. Remember to use "Progra~1" instead of "Program Files", the space in between causes unexpected problemss. If your Java Folder is inside "Program Files(x86) instead, use Progra~2. 

  1. Right click on the My Computer icon, click on Properties and then on Advanced System Settings

  2. Click on Environment variables

  3. Add a new User Environment Variable called PATH or modify it if it already exists to include the path to the java.exe file. In most cases, you can just copy what you typed in JAVA_HOME and add /bin in the end.
  4. Check that java is working by opening the command prompt and typing java -version. Make sure you open a fresh command prompt and not try this on a command prompt that was already opened when you added environmental variables.

Step 3: Install Maven

This is perhaps the trickiest part of the whole setup. Most installation instructions do not even mention this but Leningin requires Maven to download dependencies. So you need to set it up before proceeding to download and install Leningin.

  1. Download and extract maven to any folder of your choice. Add the location to the mvn.exe file that is located inside the bin folder of your maven installation directory to the PATH variable.
  2. Open a fresh command prompt and type mvn -version to confirm.

Step 4: Install leningin

Download Leningin Windows Installer and install  it.

Step 5: Download LightTable

  1. Download LightTable and click on LightTable.exe to fire it up.
  2. Press Ctrl+Space to open up the context menu and type Add Connection. From the suggestion box, choose Connection: Add Connectio and click on LightTable UI.
  3. Now type (inc 4) and press Ctrl+Enter to check if everything is working. LightTable will take some time to download all the dependencies and you will see the result as 5.

Step 6: Connecting LightTable to a web project

  1. Click on the File Icon in LightTable and click on Open Folder. Now navigate to the root folder of your project(the one containing the project.clj file).
  2. Navigate to the root folder of your web project in a command prompt. Type lein figwheel. You will see the port number displayed.
  3. Fire up your browser and navigate to localhost:[port]
  4. Make changes to the source files and save them. You'll be able to see the changes you've just made in the browser immediately.