clojure类路径问题为(require)函数? [英] clojure classpath problem for (require) function?

查看:190
本文介绍了clojure类路径问题为(require)函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CLASSPATH具有/ Users / smcho / Desktop / clojure作为其路径之一,此目录具有文件hello.clj。

CLASSPATH has the "/Users/smcho/Desktop/clojure" as one of its path, and this directory has the file hello.clj.

运行clojure,

Running clojure, and running (require 'hello) give this error message.


java.io.FileNotFoundException: Could not locate hello__init.class or hello.clj on classpath:  (NO_SOURCE_FILE:0)



当我将目录更改为/Users/.../clojure (require'hello),没有问题。的。位于CLASSPATH上。

When I change directory to "/Users/.../clojure", and run the same (require 'hello), there's no problem. The . is on the CLASSPATH.

运行


java -cp /Users/smcho/bin/jar/clojure.jar:/Users/smcho/Desktop/clojure clojure.lang.Repl

也可以。

为什么clojure无法在CLASSPATH上找到源代码?

Why clojure can't find the source on the CLASSPATH?

推荐答案

p>像Alex提到的,如果使用-cp参数启动java,那么不会引用CLASSPATH环境。所以,而不是

Like Alex mentioned, if you start java with the -cp argument, then the CLASSPATH environment is not referenced. So, instead of

java -cp /Users/smcho/bin/jar/clojure.jar clojure.lang.Repl

使用

java -cp /Users/smcho/bin/jar/clojure.jar:$CLASSPATH clojure.lang.Repl

您可以从Clojure中检查您的Java类路径:

You can examine your java classpath from within the Clojure repl:

(doseq [p (.getURLs (java.lang.ClassLoader/getSystemClassLoader))] (println (.getPath p)))

这篇关于clojure类路径问题为(require)函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆