如何在clojure中编译文件

jcu*_*bic 10 java compilation clojure

我创建了文件"hello.clj"

(ns clojure.examples.hello
    (:gen-class))

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

并尝试编译

clojurec hello.clj

但我得到了这个错误

Exception in thread "main" java.io.FileNotFoundException: Could not locate hello/clj__init.class or hello/clj.clj on classpath: 
    at clojure.lang.RT.load(RT.java:398)
    at clojure.lang.RT.load(RT.java:367)
    at clojure.core$load__5058$fn__5061.invoke(core.clj:3734)
    at clojure.core$load__5058.doInvoke(core.clj:3733)
    at clojure.lang.RestFn.invoke(RestFn.java:413)
    at clojure.core$load_one__5010.invoke(core.clj:3578)
    at clojure.core$compile__5065$fn__5067.invoke(core.clj:3744)
    at clojure.core$compile__5065.invoke(core.clj:3743)
    at clojure.lang.Var.invoke(Var.java:346)
    at clojure.lang.Compile.main(Compile.java:56)

我也尝试将它放在文件中并运行clojore hello.clj

(compile 'clojure.examples.hello)

但得到了同样的错误.

Mic*_*zyk 6

调用的名称空间clojure.examples.hello需要驻留在目录中调用的文件hello.clj$CPDIR/clojure/examples,其中$CPDIR包含在JVM的类路径中的目录.

通常,尝试设置类路径并手动发出编译命令毫无意义.改用Leiningen ; README对您需要做的事情有一个非常详尽的解释.