Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure REPL not launching at Windows command prompt

I have placed the clojure-1.4.0.jar path (C:\clojure-1.4.0\clojure-1.4.0.jar) in my CLASSPATH environment variable. Now when I try to launch the REPL from the command line with the following code:

java -cp clojure-1.4.0.jar clojure.main

I get an error:

Error: Could not find or load main class clojure.main

It used to work before I set up emacs. Any ideas.

like image 552
letroot Avatar asked Mar 07 '13 16:03

letroot


People also ask

How do I launch REPL in Clojure?

To start a REPL session in Eclipse, click the Menu option, go to Run As → Clojure Application. This will start a new REPL session in a separate window along with the console output.

What is Clojure REPL?

A Clojure REPL (standing for Read-Eval-Print Loop) is a programming environment which enables the programmer to interact with a running Clojure program and modify it, by evaluating one code expression at a time.


1 Answers

You can either add clojure jar file to CLASSPATH environment variable:

/some/where % CLASSPATH=/tmp/clojure-1.4.0.jar java clojure.main

or specify it directly in java arguments:

/some/where % java -cp /tmp/clojure-1.4.0.jar clojure.main

Setting CLASSPATH variable and providing -cp argument to java command at the same time is pointless, because -cp argument overrides CLASSPATH completely. This is the cause of your problem: you seem to be invoking java command not from the directory where clojure-1.4.0.jar is located, so -cp clojure-1.4.0.jar switch makes java program try to locate clojure-1.4.0.jar in the current directory and ignore CLASSPATH. Since there is no clojure-1.4.0.jar in the current directory, the command fails.

like image 194
Vladimir Matveev Avatar answered Sep 23 '22 07:09

Vladimir Matveev