Métodos computacionales

Setting Up Clojure with IntelliJ IDEA

For this course we will be using the Clojure programming language with the IntelliJ development environment. IntelliJ is available for Windows, macOS, and Linux.

Installing IntelliJ IDEA and Cursive

  1. Download and install the free IntelliJ IDEA Community Edition for your operating system. Use all the default options when installing the program. Do NOT install the 30-day trial IntelliJ IDEA Ultimate.
  2. The first time you run IntelliJ select the Plugins option from the welcome screen:

    Select the Marketplace tab and type cursive in the search box:

    Install the Cursive plugin using the Install button. Press the Restart IDE button when it appears.

Project Creation

  1. Download and extract the Clojure SDK files.

  2. In the IntelliJ IDEA welcome screen press the New Project button.

  3. From the New Project window, select the Clojure option from the left panel, then select Bare project from the middle panel, and finally press the Next button.

    Unselect the Create Sources Root radio button. Type in the Project name and Project location fields. Select the Use library radio button and press the Create... button.

    In the New Library Files window, go to the clojure_sdk directory (from step 1) and select all the JAR files contained there (use the Ctrl key [or Cmd key if your using macOS] to select multiple files):

    Press the OK button and then the Create button at the bottom of the dialog window.

  4. The first time you create a Clojure project a Licence Required message will appear at the bottom of the main window inside an event log pane.

    You’ll need to request a licence for Cursive. Follow the previous link, and in the Choose licence type option select Non-Commercial because you’ll be using Cursive for student work (and otherwise you’d have to pay $99 USD for it!). You’ll receive the Licence Certificate by e-mail.

    Once you’ve gotten the licence, in the main menu go to Help, select Register Cursive..., and copy/paste your Licence Certificate.

Using the REPL

A REPL (Read-Eval-Print-Loop), also known as language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user. You can integrate the Clojure REPL into IntelliJ.

  1. In IntelliJ’s main menu choose Run and then select Edit Configurations... In the Run/Debug Configurations window, press the plus symbol (+) at the top left corner and select Clojure REPL and Local.

  2. Specify a Name (for example The REPL) and select the nREPL radio button. Press the OK button.

  3. Press the green play button on the top right-hand side of the main window to open the REPL window.