navgeet
navgeet

Reputation: 1007

Switch to a specific clojure version from REPL

I have two apps app1.jar and app2.jar, with Clojure 1.2 included in app1 and Clojure 1.4 in app2.

When I run:

java -cp app1.jar:app2.jar clojure.main

to open a REPL, it uses Clojure 1.2. Is there a way to switch to Clojure 1.4?

Upvotes: 1

Views: 153

Answers (1)

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91554

As with many such question the anser is use leiningen lein2 has a profiles feature that lets you properly handle multiple versions of clojure. This is especially useful because the clojure.contrib libraries are very different between those two versions. It took me longer to type this sentence than to install, configure and get a project started with leiningen. It really is worth it.

In practice you will need to have two instances of clojure running, one with each profile (version) and you can then either have two REPLs (one attached to each) or one repl (using nrepl) that you switch back and forth.

There is an unfortunate amount of old documentation on the net for Clojure that predates mass adoption of Leiningen.

Upvotes: 3

Related Questions