Question

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?

Was it helpful?

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

OTHER TIPS

Is clojure.jar and clojure-contrib.jar in your current working directory? If not, you need to specify the full path to the JAR files in the CLASSPATH.

It's clojure.contrib, not clojute-contrib. Note dot versus dash.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top