views:

198

answers:

1

I can't seem to find a way to launch the Clojure REPL with the contrib library included. If I understood the documentation correctly then this command should do it:

C:\clojure-1.1.0>"%ProgramFiles%\Java\jre6\bin\java.exe" -cp clojure.jar:clojure
-contrib.jar clojure.main
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/main
Caused by: java.lang.ClassNotFoundException: clojure.main
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: clojure.main.  Program will exit.

But as you can see, it fails. I did copy the clojure-contrib.jar to the C:\clojure-1.1.0 folder.

Can someone help me get it right?

Update
Thanks to Michał's post I noticed that my error was using a colon where I had to use a semi-colon. This works:

C:\clojure-1.1.0>"%ProgramFiles%\Java\jre6\bin\java.exe" -cp clojure.jar;clojure-contrib.jar clojure.main
Clojure 1.1.0
user=> 
+4  A: 

(Answer updated to make the actual solution explicit, whereas it was somewhat hidden in the original...)

The classpath string on Windows uses ; as the separator. E.g.

java.exe -cp "C:\clojure-1.1.0\clojure.jar;C:\clojure-1.1.0\clojure-contrib.jar" clojure.main

Alternatively, you can use a wildcard to include all jars in the given directory in the classpath (that's a JDK 1.6 addition, wouldn't work with 1.5):

java.exe -cp "C:\clojure-1.1.0\*" clojure.main

(I think using double quotes here is ok in Windows, can't check though...)

Michał Marczyk
Thanks! It's not really the full paths, I simply had to use a semi-colon instead of a colon as separator for the jar files! Aarg..
StackedCrooked
Hah! Good that you noticed it -- I did notice the difference in the separators and even double checked the docs on it, then for some unfathomable reason neglected to mention it explicitly in the answer. Not to mention I also failed to notice the `C:\clojure-1.1.0>` prompt in the question... All's well that ends well, I guess. :-) I've made an edit now for the benefit of future readers.
Michał Marczyk