I'm new to clojure. I have a jar file I want to play with in a clojure repl, but I've failed to do so with leiningen 2.
I have tried placing the jar file in src/myjar.jar and also in src/org/mydomain/myjar.jar
When I run lein repl I get errors stating that leiningen can not find my artifact, and a reference to a page about repeatability which I do not understand.
Here is my project.clj (with the real name of myjar)
(defproject cljliveordead "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.3.0"]
[org.allen.temporalintervalrelationships/time "0.2" :extension "jar"]])
To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application. This will start a new REPL session in a separate window along with the console output.
A Clojure REPL (standing for Read-Eval-Print Loop) is a programming environment which enables the programmer to interact with a running Clojure program and modify it, by evaluating one code expression at a time.
You can just press ctrl-d (*nix) or ctrl-z (Windows) to exit the REPL.
You can use local jars using the lein-localrepo plugin. Add this line to your project.clj
:plugins [[lein-localrepo "0.4.0"]]
Then install the jar to the local repository using
lein localrepo install <path-to-jar> org.allen.temporalintervalrelationships/time 0.2
You can check that the file is installed by running lein localrepo list
and check that lein can resolve the project dependencies using lein deps
. If all is well then you can start playing with the jar using lein repl
.
Leiningen doesn't like local jars due to its goal of repeatable builds. If this was a real project using a third party closed source jar then the best thing to do is install it in a local Nexus repository and add a reference to that repository to your project.
However, this all seems a bit heavyweight for what you are trying to achieve. If all you want to do is play with the jar in the REPL then create a simple project like this
(defproject clojure-time "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.4.0"]
[com.cemerick/pomegranate "0.0.13"]])
and use the pomegranate library to add the jar to your classpath manually
(require '[cemerick.pomegranate :as p])
(p/add-classpath "jsr-310-ri-0.6.3.jar")
(javax.time.Instant/now)
and play away.
the hackish way is to just put it into /proiject/path/lib/
and the 'proper' way is to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With