简体   繁体   English

如何在带有逆时针方向的Eclipse中使用已编译的Clojure类

[英]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.

相关问题 如何使Eclipse / Counterclockwise使用Macports安装Clojure - How to make Eclipse/Counterclockwise use Macports installed Clojure 如何在Eclipse / CounterClockWise中重新格式化/重新生成Clojure代码? - How to reformat/reindent Clojure code in Eclipse/CounterClockWise? 在日食中运行clojure(逆时针) - running clojure in eclipse (counterclockwise) 用CounterClockwise和Eclipse评估Clojure REPL - Evaluation in Clojure REPL with CounterClockwise and Eclipse 如何使用Eclipse和CounterClockwise查看Clojure函数的调用层次结构 - How to see a Clojure function's call hierarchy using Eclipse and CounterClockwise 无法在Eclipse逆时针Clojure插件中创建项目 - Cannot Create Project in Eclipse Counterclockwise Clojure Plugin Eclipse(逆时针)-新的Clojure项目:[Exception]无法加载模板,Leiningen - Eclipse (Counterclockwise)- New Clojure Project: [Exception] Could not load template, Leiningen 逆时针在eclipse中不使用步进调试器? - Counterclockwise doesn't use stepping debugger in eclipse? Eclipse-Clojure-逆时针插件-用于评估REPL名称空间(而非文件名称空间)中选择的快捷方式 - Eclipse - Clojure - Counterclockwise plugin - shortcut for evaluating selection in REPL namespace (not file namespace) 如何在Eclipse的CounterClockwise-REPL中运行doc命令? - How is it possible to run the doc-command in a CounterClockwise-REPL in Eclipse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM