Leiningen and Clojure dependence

I am very new to clojure, but I have been unable to find good resources and examples on the Internet, so I hope someone can point me in the right direction. I have started a project with lein, project .clj looks like this:

(defproject scratch "1.0"
:description ""
:main scratch.core
:dependencies [
[org.clojure/clojure "1.3.0"]
[org.clojars.jyaan/slick "247.1"]
])

and src / scratch / core.clj looks like this:

(ns scratch.core 
(:import org.newdawn.slick))
< br />(defn -main [] (println "hello world"))

As far as I know, this is correct, but when I try to run lein run, I get a ClassNotFoundException.

I made a jar tf on the lib/slick-247.1.jar file and confirmed that it has a directory structure, indicating that it has that namespace (org/newdawn/slick/etc…). I’m sure this is one Simple mistake, but I can’t see what it is, does anyone have any ideas?

I think the problem is that you are trying to import the entire package, just like “import org.newdawn in Java .slick.*”. You can’t do this in Clojure, but you have to import every class you want to use.

The shortest you can get is:

(:import (java.io BufferedReader Bits BufferedWriter))

I am very new to clojure, but I have not been able to find it online Good resources and examples, so I hope someone can point me in the right direction. I have started a project with lein, and project.clj looks like this:

 (defproject scratch "1.0"
:description ""
:main scratch.core
:dependencies [
[org.clojure/clojure "1.3.0"]
[org.clojars.jyaan/slick "247.1"]
])

and src / scratch / core.clj look like this:

< pre>(ns scratch.core
(:import org.newdawn.slick))

(defn -main [] (println “hello world”))

As far as I know this is correct, but when I try to run lein run, I get a ClassNotFoundException.

I made a jar tf on the lib/slick-247.1.jar file and confirmed that it has A directory structure, indicating that it has the namespace (org/newdawn/slick/etc…). I’m sure this is a simple error, but I can’t see what it is. Does anyone have any ideas?

I think the problem is that you are trying to import the entire package, just like “import org.newdawn.slick.*” in Java. In Clojure you can’t Do this, but you must import every class you want to use.

The shortest you can get is:

(: import (java.io BufferedReader Bits BufferedWriter))

Leave a Comment

Your email address will not be published.