gpt4 book ai didi

java - Clojure 中的编译问题

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:19:19 26 4
gpt4 key购买 nike

我一直在尝试在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com