java - Clojure 中的编译问题

标签 java clojure compilation classpath

我一直在尝试在 Clojure 中编译一个非常简单的 test.clj,但没有成功。我有一个 threadClojure Google Group 上有几个回应,但没有任何帮助。快速总结一下,这是我的 clojure 文件:

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

(defn -main
    [gre]
    (println (str "Hello " gre)))

基本上它是 Clojure documentation 中提供的示例文件.

我已将此文件适本地放在 clojure/src/test/test.clj 中,并且应该能够使用 (compile 'test.test) 进行编译,但是我不断收到错误消息:

java.io.IOException: The system cannot find the path specified (test.clj:1)
which leads me to believe it is a classpath problem. I have tried running Clojure with all the standard commands given in the Clojure documenation as well as the latest suggestion from the thread java -classpath .;src;classes;clojure.jar clojure.main.

If it helps, my filesystem looks like this:

-+-clojure
 +-classes/
 +-+-src/
 | |-+-test/
 | | \-test.clj
 +-\-test.clj
 +-test.clj
 +-clojure.jar

附言我在 Vista Ultimate 上运行,所以它可能可能是权限问题,但我检查了权限并没有发现任何问题。

最佳答案

在 Windows 上编译 test.clj 的控制台输出:

C:\clojure>dir /b/s
C:\clojure\classes
C:\clojure\src
C:\clojure\src\test
C:\clojure\src\test\test.clj

C:\clojure>java -cp c:\dev\clojure.jar;.\src;.\classes clojure.lang.ReplClojure
user=> (compile 'test.test)
test.test
user=>

生成的class文件在classes目录下。

另外,请注意您在main 中缺少右括号。更正版本:

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

(defn -main
    [gre]
    (println (str "Hello " gre)))

关于java - Clojure 中的编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/607368/

相关文章:

java - 有没有办法访问 Springframework 存储库 "refresh"?

java - 我如何查看与 Clojure 中的对象关联的方法?

compilation - 使用 gradle 将 jar 添加到类路径

java - 将对象存储在我的 2D 数组中并将其显示在 JFrame 上

java - 执行任务操作 :app:processDebugManifest error Android Studio

java - 斯卡拉-Java =? (或 Clojure - Java =?)

concurrency - 如何在 Clojure 中创建一个持续运行的后台进程?

compiler-construction - 其他有关Stalin编译器如何进行残酷优化的引用?

compilation - 编译语言和解释语言之间的区别?

java - Android-错误膨胀类 fragment