简体   繁体   English

如何在Windows上安装clojure-contrib?

[英]How to install clojure-contrib on Windows?

I can't seem to find a way to launch the Clojure REPL with the contrib library included. 我似乎无法找到一种方法来启动包含contrib库的Clojure REPL。 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. 我确实将clojure-contrib.jar复制到了C:\\clojure-1.1.0文件夹中。

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. 感谢Michał的帖子,我注意到我的错误是使用冒号,我不得不使用分号。 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=> 

(Answer updated to make the actual solution explicit, whereas it was somewhat hidden in the original...) (答案更新,以使实际解决方案明确,而它有点隐藏在原始......)

The classpath string on Windows uses ; Windows上的类路径字符串使用; as the separator. 作为分隔符。 Eg 例如

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): 或者,您可以使用通配符在类路径中包含给定目录中的所有jar(这是JDK 1.6的添加,不适用于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...) (我认为在Windows中使用双引号是可以的,但不能检查...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM