Faris Nasution
Faris Nasution

Reputation: 3610

Could not locate file when importing it

I just started playing with clojure, and I have a question.

I create a folder called testingclojure in ~/ and it contains a file called core.clj which has a simple function like this:

(ns testingclojure.core)

(defn greetings 
  [{:keys [name age]}]
  (format "Hello my name is %s and I'm %s years old" name age))

So the filepath is: ~/testingclojure/core.clj

Meanwhile I'm in ~/, and I want to use it in repl, so I type:

(use '[testingclojure [core :as c]])

Unfortunately, I got an error, something like "Could not locate testingclojure/core.clj". How to solve this problem?

Upvotes: 2

Views: 84

Answers (1)

KobbyPemson
KobbyPemson

Reputation: 2539

How do you invoke the repl? Are you using leiningen or just the clojure jar?

You need to include the current folder if you are using the clojure jar

java -cp [path to clojure jar];.; clojure.main

if you are using leiningen place your code in the src folder or use the src directive in your project.clj to point it to the right source folder.

Upvotes: 2

Related Questions