如何在clojure中编译文件 [英] How to compile file in clojure

查看:194
本文介绍了如何在clojure中编译文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已建立档案「hello.clj」

I've created file "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

I try also to put this in the file and run clojore hello.clj


(compile 'clojure.examples.hello)


$ b b

但是得到了相同的错误。

But got the same error.

推荐答案

名为 clojure.examples.hello 需要驻留在目录中的 hello.clj 文件中。 $ CPDIR / clojure / examples $ CPDIR 是JVM类路径中包含的目录。

A namespace called clojure.examples.hello needs to reside in a file called hello.clj in a directory $CPDIR/clojure/examples, where $CPDIR is a directory included in the JVM's classpath.

一般来说,并用手发出编译命令没有什么意义。改用 Leiningen ; README对你需要做的事情有相当详尽的解释。

In general, trying to set the classpath and issue the compilation command by hand makes little sense. Use Leiningen instead; the README has a pretty thorough explanation of what you'll need to do.

这篇关于如何在clojure中编译文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆