温馨提示:本文翻译自stackoverflow.com,查看原文请点击:compilation - Compiling Clojure?
clojure compilation

compilation - 编译Clojure?

发布于 2020-04-25 18:29:26

我在这里感觉有点傻,但是无法编译Clojure Hello World。

目录结构:

hello-world/
  clojure-1.1.0.jar
  build/
    classes/
  src/
    test/
      hello.clj

hello.clj:

(ns test.hello
  (:gen-class))

(defn -main [& args]
  (println "Hello" (nth args 0)))

相互作用:

$ cd hello-world
[hello-world]$ java -cp ./clojure-1.1.0.jar:./build/classes:./src clojure.main
Clojure 1.1.0
user=> (require 'test.hello)
nil
user=> (test.hello/-main "there")
Hello there
nil
user=> (compile 'test.hello)
java.io.IOException: No such file or directory (hello.clj:2)
user=> *compile-path*
"classes"
user=> (doseq [p (.split (System/getProperty "java.class.path") ":")] (println p))
./clojure-1.1.0.jar
./build/classes
./src
nil

因此,我可以从REPL加载并调用文件,但无法编译。

根据clojure.org,编译需要

  • 名称空间必须与相对于类路径的文件路径匹配-检查
  • * compile-path *必须在类路径上-检查
  • ns形式的:gen-class参数-检查

据我所知,我从一年前就发现了这篇文章,我的所作所为完全相同,但它不起作用。

我想念什么?

系统:OS X 10.6,Java 1.6.0,Clojure 1.1

查看更多

提问者
j-g-faustus
被浏览
92
Alex Ott 2010-06-27 18:50

为什么不使用雷宁根与手动编译代码相比,使用它要容易得多。您可以将关于它的文章用作介绍...