Using core.matrix in a IntelliJ IDEA cursive project

215 Views Asked by At

I am trying to use core.matrix (https://clojars.org/net.mikera/core.matrix/versions/0.33.2) in a simple project in IntelliJ IDEA with Cursive plugin. I am just learning Clojure with some code and the REPL but I can't figure out how to "import" it. Do I have to download a .jar and put it in the lib folder? Which command is used to call those functions in REPL? Do I have to edit the project.iml?

I am aiming for the simplest way of doing it, as simple as writing some code in the REPL, no leiningen projects if it is possible.

1

There are 1 best solutions below

0
On

Yuck. I just created a Clojure project in IntelliJ for the first time. My recommendation is not to. Instead get Leiningen. Use 'lein new whatever-your-app-is-called'. Then import the project into IntelliJ. Then add any dependencies to the project.clj. Cursive integrates with Leningen and Cursive suggests using Leiningen. To the best of my knowledge it can't be done purely via the REPL (the REPL has to be able to find the libraries, something has to tell it where they are, either the IDE or Leiningen).

Leiningen is the simplest way of doing it.

Using Leiningen you'll have a project.clj file. In there is a :dependencies section that takes a vector of libraries to use (org.clojure/clojure being one of them). If you add [net.mikera/core.matrix "0.33.2"] to the vector in :dependencies leiningen should fetch it for you.

Your :dependencies section should look something like this:

:dependencies [[org.clojure/clojure "1.6.0"]
               [net.mikera/core.matrix "0.33.2"]]

EDIT: Leiningen is the recommended way of using Cursive with IntelliJ Idea. In order to do without see Configuring Module Dependencies and Libraries in the jetbrains idea documentation.