Leiningen and Clojure

I am new to clojure, but I am having trouble finding good resources and examples on the Internet, so hopefully someone can point me in the right direction. I started the 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)) (defn -main [] (println "hello world")) 

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

I made jar tf in the file lib / slick-247.1.jar and confirmed that it has a directory structure that indicates that it has this namespace (org / newdawn / slick / etc ...). I am sure this is a simple mistake, but I can’t understand what it is, does anyone have any ideas?

+4
source share
1 answer

I think the problem is that you are trying to import the whole package, for example, "import org.newdawn.slick. *" In Java. In Clojure, you cannot do this, but you need to import every class that you want to use.

The shortest thing you can get:

 (:import (java.io BufferedReader Bits BufferedWriter)) 
+4
source

All Articles