File io Can';不加载文件
我在Windows上的以下目录中有文件male_female.clj:File io Can';不加载文件,file-io,clojure,File Io,Clojure,我在Windows上的以下目录中有文件male_female.clj: C:\Documents and Settings\vreinpa\My Documents\Books\ProgrammingClojure\code\src\examples 在启动REPL之前,我切换到该目录: U:\>c: C:\>cd C:\Documents and Settings\vreinpa\My Documents\Books\ProgrammingClojure\code\src\exa
C:\Documents and Settings\vreinpa\My Documents\Books\ProgrammingClojure\code\src\examples
在启动REPL之前,我切换到该目录:
U:\>c:
C:\>cd C:\Documents and Settings\vreinpa\My Documents\Books\ProgrammingClojure\code\src\examples
然后,我启动REPL:
C:\Documents and Settings\vreinpa\My Documents\Books\ProgrammingClojure\code\src\examples>lein repl
Warning: classpath not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic classpath or change the name.
REPL started; server listening on localhost:13278.
然后我尝试加载该文件,但出现以下错误:
user=> (load-file "male_female.clj")
user=> FileNotFoundException male_female.clj (The system cannot find the file specified) java.io.FileInputStream.open (:-2)
我做错了什么?该文件肯定位于我在开始REPL之前更改的目录中。您正在使用吗?我只是克隆了它,并尝试了同样的事情(虽然是在Mac上),但也出现了同样的错误
如果是,请尝试从Git repo的根运行lein repl
,然后使用(加载“examples/male\u female”)
。然后,您可以通过切换到带有(在ns'examples.male-female中)
的名称空间,或完全使用完全限定名:examples.male-female/m
等来访问此文件中的定义。这对我很有用
我不确定load file
在哪里,但我认为load
将在Java类路径中查找。您可以使用(System/getProperty“java.class.path”)
从Clojure REPL检查类路径
编辑
在阅读了加载文件后,我对它进行了实验,发现它也起了作用:(加载文件“src/examples/male\u female.clj”)
,不管我在项目中的哪个位置。这可能与Leiningen及其认为的项目根有关