1

I'm trying to use functions from other jar files.

Creation of local jar file

I downloaded sample sources from the book Programming Clojure 2nd Ed, and created a jar file with lein jar command.

Use the local jar file

From the hints in this post, I copied the jar file in lib/ directory, then I could add :resource-paths ["lib/programming-clojure-1.3.0.jar"] in the project.clj.

Test in REPL

With lein classpath command, I could check that the jar file is in class path. With lein repl, I could use the functions in the jar file.

mire=> (require '[examples.introduction :as e])
nil
mire=> (take 10 examples.introduction/fibs)
(0 1 1 2 3 5 8 13 21 34)

Isses with emacs/cider

I created a t.clj source in the src/ directory, launched emacs with emacs src/t.clj &, and started REPL with M-x cider-jack-in.

I wrote this code, and executed it with C-x C-e.

(ns t (:require '[examples/introduction :as ex]))

However, I got a message that the file is not found.

java.io.FileNotFoundException: Could not locate introduction__init.class or introduction.clj on    

classpath:

What might be wrong?

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871

1 Answers1

2

The namespace is examples.introduction. Also, you don't need to quote the vector inside the ns macro. Try:

(ns t (:require [examples.introduction :as ex]))

See some examples of use for the ns macro here.

Also, it's customary to have at least two segments in namespaces. Yours could be mynamespace.t for example.

Diego Basch
  • 12,764
  • 2
  • 29
  • 24