Problem when trying to import SAT4J java class

146 views
Skip to first unread message

Ronan BARZIC

unread,
May 5, 2014, 8:29:59 PM5/5/14
to clo...@googlegroups.com
Hi,

I'm trying to use the SAT4J java library (http://www.sat4j.org) from Clojure.
I've create a clojure app with "lein new app sat4j-app"

I've edited the project.clj file to :

(defproject sat4j-app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :license {:name "Eclipse Public License"
  :dependencies [
                 [org.clojure/clojure "1.5.1"]
                 [org.ow2.sat4j/org.ow2.sat4j.sat "2.3.5"]
                 [org.ow2.sat4j/org.ow2.sat4j.core "2.3.5"]  
                 ]
  :main sat4j-app.core
  :profiles {:uberjar {:aot :all}})

If I run lein deps, I can see that leiningen can find the sta4j modules :
....
Retrieving org/ow2/sat4j/org.ow2.sat4j.sat/2.3.5/org.ow2.sat4j.sat-2.3.5.pom from central
Retrieving org/ow2/sat4j/org.ow2.sat4j.pom/2.3.5/org.ow2.sat4j.pom-2.3.5.pom from central
Retrieving org/ow2/ow2/1.5/ow2-1.5.pom from central
Retrieving org/ow2/sat4j/org.ow2.sat4j.core/2.3.5/org.ow2.sat4j.core-2.3.5.pom from central
....

And I can compile and run the default code (no sat4j import yet).
The problem occurs when I try to use import in my main clojure code :

(ns sat4j-app.core
  (:gen-class)
  (:import org.ow2.sat4j/org.ow2.sat4j.core Vec ))

I then get a Class not found exception (Vec is suppoed to be defined in the core module)
I don't know which syntax to use in the import statement. 
I've also tried (:import org.ow2.sat4j.core Vec ), (:import org.ow2.sat4j.core.Vec ) without success.

To make think even more confusing, I did a local build of sat4j and I found (using javadoc html page) that the Vec class is defined as org.sat4j.core.Vec<T>
not org.ow2.sat4j.core.Vec<T>. 
So I tried (:import org.sat4j.core.Vec ) and (:import org.sat4j.core Vec ) without success.

Any clue ?


Thank you


Ronan










Jason Felice

unread,
May 5, 2014, 8:50:05 PM5/5/14
to clo...@googlegroups.com
The form should be:

(:import [org.sat4j.core Vec]) ; note the square braces.


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ronan BARZIC

unread,
May 6, 2014, 8:48:42 PM5/6/14
to clo...@googlegroups.com
Thank - That fixed the problem - I was using an example from "Clojure Programming" (P 328) and they didn't use square braquets - probably a typo ?

Ronan






You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/4XbuiyUw1ac/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages