从 jar 导入 clojure 函数
我正在使用 Clojure,但不知道如何从 clojure-contrib.jar 导入函数。根据 this 答案,我正在执行以下操作
:像这样 REPL:
java -cp clojure.jar:clojure-contrib.jar clojure.main
然后尝试导入一个函数:
user=> (use '[clojure-contrib.duck-streams :only (writer reader)])
它不起作用,并且出现以下错误:
java.io.FileNotFoundException:无法在类路径上找到 clojure_contrib/duck_streams__init.class 或 clojure_contrib/duck_streams.clj:(NO_SOURCE_FILE:0)
用点而不是破折号尝试也不起作用:
user=> (use '[clojure.contrib.duck-streams :only (writer reader)])
我得到的错误大多相同:
java.io.FileNotFoundException:无法在类路径上找到 clojure/contrib/duck_streams__init.class 或 clojure/contrib/duck_streams.clj:(NO_SOURCE_FILE:0)
我做错了什么?
I'm playing around with Clojure, and I can't figure out how to import a function from clojure-contrib.jar. Working from this answer, I'm doing the following:
Running the REPL like so:
java -cp clojure.jar:clojure-contrib.jar clojure.main
Then trying to import a function:
user=> (use '[clojure-contrib.duck-streams :only (writer reader)])
It doesn't work, and I get the following error:
java.io.FileNotFoundException: Could not locate clojure_contrib/duck_streams__init.class or clojure_contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)
Trying it with a dot instead of a dash also doesn't work:
user=> (use '[clojure.contrib.duck-streams :only (writer reader)])
I get mostly the same error:
java.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
clojure.jar
和clojure-contrib.jar
是否在您当前的工作目录中?如果没有,您需要在 CLASSPATH 中指定 JAR 文件的完整路径。Is
clojure.jar
andclojure-contrib.jar
in your current working directory? If not, you need to specify the full path to the JAR files in the CLASSPATH.这应该可以工作
我现在没有 clojure 方便检查,但
也应该可以工作
This should work
I don't have clojure handy right now to check, but
should also work
它是 clojure.contrib,而不是 clojute-contrib。注意点与破折号。
It's clojure.contrib, not clojute-contrib. Note dot versus dash.