开发者

How to use a compiled Clojure class in Eclipse with Counterclockwise

I created a basic hello world class in eclipse with clojure and counterclockwise and I'm able to compile it with clojure no problem.

(ns ca.ckovacs.test.helloWorld
    (:gen-class))

(defn -main
  [greetee]
  (println (str "Hello " greetee "!")))

I see that this generates three classes in my /classes folder:


helloWorld__init.class
helloWorld$_main__135.class
helloWorld$loading__6309__auto__133.class

But why don't I get a helloWorld.class?

I eventually want to be able to use a Clojure compiled class within Eclipse.

I must be missing something obvious, but reading through the Compilation page at clojure.org, the posted example hello wor开发者_Go百科ld says you can just load the helloWorld class like any other java class.

Thanks.


I don't know what the problem was, but I ended up renaming my package name and I get the helloWorld.class file as expected.

I suspect the problem may be because I had two seperate source paths (one for Java, one for Clojure) that shared the same package namespace.


Hmmm... Since no one else has provided an answer, I'll try to give some guidance even though I don't use Eclipse or Counterclockwise.

If you want to treat your Clojure functions like static methods when calling from Java, you need to add some information to your (gen-class) statement, particularly :methods keyword.

See my answer to "Calling Clojure from Java" a few days ago. It provides an answer developed on NetBeans and enclojure that may provide some guidance for your problem.

Dealing with classes/object/inheritance between the two languages is a bit more complicated.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜