4
votes

I'm fairly new to clojure but I've been having trouble finding good resources and examples online, so hopefully someone could point me in the right direction. I've 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))    

(defn -main [] (println "hello world"))

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

I did a jar tf on the lib/slick-247.1.jar file and confirmed it has a directory structure which would indicate that it has that namespace (org/newdawn/slick/etc...). I'm sure it's a simple mistake but I can't see what it is, does anyone have any ideas?

1

1 Answers

3
votes

I think the issue is that you are trying to import the whole package, like a "import org.newdawn.slick.*" in Java. In Clojure you cannot do this, but you have to import each class that you want to use.

The shortest that you can get is:

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