7

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.

Mike
  • 3,219
  • 23
  • 29

2 Answers2

9

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)))
McDowell
  • 107,573
  • 31
  • 204
  • 267
  • Excelent! Thank-yee greatly, it works like a charm! Also, I'm going to edit the question because I that close-paren just was cut off from the copy/paste I did. – Mike Mar 03 '09 at 19:34
  • HI I am getting the same problem. What could be wrong? I tried your solution: C:\clojure>java -cp clojure-1.0.0.jar;.\src;.\classes clojure.lang.Repl user=> (compile 'test.test) java.io.IOException: The system cannot find the path specified (test.clj:1) – unj2 Jul 24 '09 at 03:24
  • 1
    This means that you didn't have the classes/ directory in your CLASSPATH. –  Feb 03 '10 at 19:53
0
 C:\clojrue\java -cp .\src;.\classes;clojure.jar 
    -Dclojure.compile.path=classes clojure.lang.Compile test.test
aposto
  • 566
  • 5
  • 14