Using libraries without Lein

206 views
Skip to first unread message

Kashyap CK

unread,
Nov 28, 2017, 5:20:43 PM11/28/17
to Clojure
Hi,
I am trying to use clj-http in my clojure program. I am trying to do the whole thing in a "light-weight" manner - without creating a project and all or using lein. Is that possible? or do I need to use Lein?
Regards,
Kashyap 

Alex Miller

unread,
Nov 28, 2017, 5:27:17 PM11/28/17
to Clojure
Sure. You need a jar for Clojure and a jar for clj-http and then just run Java with those in a classpath:

java -cp clojure.jar:clj-http.jar my-program

There is a lighter weight tool that we've added in Clojure 1.9 (also works with 1.8) that can help in assembling classpaths and serving as a runner. All it's really doing is taking a statement of deps and building the classpath to make that call. If you're interested in that, this will be useful:

C K Kashyap

unread,
Nov 28, 2017, 5:50:28 PM11/28/17
to clo...@googlegroups.com
Thanks Alex ... just what I was looking for - putting the jars in classpath that is!

I'll try out the new tool a little later though.

Regards,
Kashyap

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/JaIX3aOZmvQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean Corfield

unread,
Nov 28, 2017, 11:05:58 PM11/28/17
to clo...@googlegroups.com

In addition to tools.deps, which reads dependencies etc from a deps.edn file, you might want to look at Boot http://boot-clj.com which allows you to use libraries via the command line without needing a project or source files etc:

 

    boot -d clj-http repl

 

This will start a Clojure REPL (anywhere) with the clj-http library loaded. Boot also has a call task that accepts Clojure code via the command-line:

 

    boot -d clj-http call -p -e “(require ‘[clj-http.client :as http])” -e ‘(http/get “http://google.com”)’

 

The -p option tells call to print the result of each expression.

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 


From: clo...@googlegroups.com <clo...@googlegroups.com> on behalf of C K Kashyap <ckka...@gmail.com>
Sent: Tuesday, November 28, 2017 2:49:53 PM
To: clo...@googlegroups.com
Subject: Re: Using libraries without Lein
 

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages