Search code examples
clojure

Clojure: Could not locate test2__init.class, test2.clj or test2.cljc on classpath in Cider


I have two files test.clj and test2.clj in the same directory.

I want to import the functions from test2.clj

test.clj looks like this:

(ns test
  (:require [test2 :refer :all])
)

test2.clj like this:

(defn showworld []
    (println "hello world")
)

But when i execute test.clj in cider, i get: Could not locate test2__init.class, test2.clj or test2.cljc on classpath.


Solution

  • You are missing the namespace declaration in test2.clj. When we :require something, we are requiring the namespace (not the file).

    Try changing test2.clj to the following:

    (ns test2)
    
    (defn showworld []
        (println "hello world"))