Including jars in clojure

I downloaded and installed the jar with Maven (as answered here ), but now I need to require it inside the project. I followed the git README instructions ( (require '[clj-http.client :as client]) ), but I still get this error:

 FileNotFoundException Could not locate clj_http/client__init.class or clj_http/client.clj on classpath: clojure.lang.RT.load (RT.java:430) 
+4
source share
3 answers

Other answers to this thread will certainly work ... But adding cans directly to your CLASSPATH or command line can be a very complex development strategy.,

The most common, idiomatic way to include banners in the clojure app is Leiningen (a simple, one-step installation on github-begginers is to check the note at the end of this answer for a reservation). Leiningen can also install the clojure environment and run your repl for you, pre-loaded into the desired jar environment.

This, in essence, is a java dependency manager and a build tool rolled into one - for example, ivy or maven Pom.xml, which we use to develop java.

A few examples of how to use Leiningen to interact with multiple libraries in a simple and scalable way:

To start the replica so that the bans in the project.clj file are in the class path:

 lein repl 

To update the banners in your maven repo specified by your project.clj:

 lein deps 

Finally, the lane allows you to export "uberjars" that are akin to "fatjars", i.e. they have all the dependencies included in the kit for you.

A small update to the new version of Lein: Note for beginners.

There are two scripts you can run to install Leiningan, it might be safer to run this one:

https://github.com/jayunit100/leiningen/blob/stable/bin/lein ( stable version)

Instead of this:

https://raw.github.com/technomancy/leiningen/preview/bin/lein (latest update which is a preview).

+5
source

when you run the java process you need to do:

 java -cp ./lib/clj-http.jar ./lib/clojure.jar clojure.main 

Basically you need both clojure.jar (where the REPL is located) and clj-http.jar in the classpath.

Assuming clj-http.jar is in a directory. / lib /. Or you can build your project with lein (a build tool similar to maven) and create it with uberjar, which I will do. There's a pretty good walkthrough on building a lane and building a uberjar here: http://zef.me/2470/building-clojure-projects-with-leiningen .

+4
source

add clj-http.jar to CLASSPATH or CP before starting clojure repl.

0
source

Source: https://habr.com/ru/post/1415185/


All Articles