Clojure can't find .clj in local directory, . and ./classes on CLASSPATH

后端 未结 5 1377
抹茶落季
抹茶落季 2020-12-05 03:13

When I evaluate (use \'hello) to load hello.clj, the REPL complains with the following error:

java.io.FileNotFoundException: Could not locate hello__init.cla         


        
5条回答
  •  清歌不尽
    2020-12-05 04:09

    I have the following lines on my .emacs:

    (setq swank-clojure-jar-path "~/src/clojure/clojure.jar"
          swank-clojure-extra-classpaths (append 
                          (directory-files "~/src/compojure/deps" t ".jar$")
                          (list
                           "~/src/swank-clojure/src/main/clojure"
                           "~/src/clojure-contrib/clojure-contrib.jar"
                           "~/src/clj/.")))
    

    I load the programe snake.clj which is at ~/src/clj and eval it (C-x h which selects the entire buffer and then C-c C-c to compile). The programs creates a namespace by name snake. Now, from emacs/slime, I do

    (use 'snake)
    

    That's it.Now invoke any function defined in the namespace.

    Your problem may be that the directory on which you have hello.clj may not be on your classpath. Also make sure you name the namespace properly. If inside hello.clj, you named your name space as hello, then you do (use 'hello).

提交回复
热议问题