Search code examples
clojureclojure-contrib

Importing clojure functions from jars


I'm playing around with Clojure, and I can't figure out how to import a function from clojure-contrib.jar. Working from this answer, I'm doing the following:

Running the REPL like so:

 java -cp clojure.jar:clojure-contrib.jar clojure.main

Then trying to import a function:

user=>  (use '[clojure-contrib.duck-streams :only (writer reader)])

It doesn't work, and I get the following error:

java.io.FileNotFoundException: Could not locate clojure_contrib/duck_streams__init.class or clojure_contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)

Trying it with a dot instead of a dash also doesn't work:

user=>  (use '[clojure.contrib.duck-streams :only (writer reader)])

I get mostly the same error:

java.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)

What am I doing wrong?


Solution

  • This should work

    (use 'clojure.contrib)
    

    I don't have clojure handy right now to check, but

    (use 'clojure.contrib :only (writer reader))
    

    should also work