Problem compiling in Clojure

旧街凉风 提交于 2020-01-12 18:45:54

问题


I've been trying to compile a very simple test.clj in Clojure without any success. I have a thread on the Clojure Google Group with several responses, but nothing has helped. To quickly summarize, here is my clojure file:

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

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

Basically it's the example file provided in the Clojure documentation.

I have placed this file appropiately in clojure/src/test/test.clj, and should be able to compile with (compile 'test.test), but I keep getting the error:

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

P.S. I am running on Vista Ultimate so it may possibly be a permissions problem, but I have checked the permissions and could not find anything wrong with them.


回答1:


Console output for compiling test.clj on Windows:

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=>

The generated class files are in the classes directory.

Also, note that you're missing a right parenthesis in your main. Corrected version:

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

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



回答2:


 C:\clojrue\java -cp .\src;.\classes;clojure.jar 
    -Dclojure.compile.path=classes clojure.lang.Compile test.test


来源:https://stackoverflow.com/questions/607368/problem-compiling-in-clojure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!