[英]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. 我使用clojure和逆时针在eclipse中创建了一个基本的hello世界类,并且可以使用clojure毫无问题地对其进行编译。
(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: 我看到这会在我的/ classes文件夹中生成三个类:
helloWorld__init.class helloWorld$_main__135.class helloWorld$loading__6309__auto__133.class
But why don't I get a helloWorld.class? 但是,为什么我没有得到helloWorld.class?
I eventually want to be able to use a Clojure compiled class within Eclipse. 我最终希望能够在Eclipse中使用Clojure编译类。
I must be missing something obvious, but reading through the Compilation page at clojure.org, the posted example hello world says you can just load the helloWorld class like any other java class. 我肯定会遗漏一些明显的东西,但是仔细阅读clojure.org的“编译”页面,发布的示例hello world表示您可以像加载其他java类一样加载helloWorld类。
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. 我不知道问题出在哪里,但是我最终重命名了程序包名称,并按预期得到了helloWorld.class文件。
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. 我怀疑问题可能是因为我有两个单独的源路径(一个用于Java,一个用于Clojure)共享相同的程序包名称空间。
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. 嗯……由于没有人提供答案,即使我不使用Eclipse或逆时针,我也会尝试提供一些指导。
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. 如果要从Java调用时将Clojure函数像静态方法一样对待,则需要向
(gen-class)
语句中添加一些信息,尤其是:methods
关键字。
See my answer to " Calling Clojure from Java " a few days ago. 几天前,请参阅我对“ 从Java调用Clojure ”的回答。 It provides an answer developed on NetBeans and enclojure that may provide some guidance for your problem.
它提供了在NetBeans和附件上开发的答案,可能会为您的问题提供一些指导。
Dealing with classes/object/inheritance between the two languages is a bit more complicated. 处理两种语言之间的类/对象/继承关系要复杂一些。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.