tags:

views:

99

answers:

3

For some reason I can't get clojure REPL working with jline, what i did was git clone the clojure repository off github then run ant to build it, then i download jline-0.9.94.jar to the directory with clojure.jar, then run the following command:

java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main

And get the following errors:

    Exception in thread "main" java.lang.ClassNotFoundException: clojure.main
 at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:317)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:164)
 at jline.ConsoleRunner.main(Unknown Source)

Here are the files in my current directory:

vvshs-macbook-2:clojure vvsh$ ls
build.xml                                 clojure-sources-1.2.0-master-SNAPSHOT.jar epl-v10.html                              src
classes                                   clojure-sources.jar                       jline-0.9.94.jar                          test
clojure-1.2.0-master-SNAPSHOT.jar         clojure.iml                               pom-template.xml
clojure-slim-1.2.0-master-SNAPSHOT.jar    clojure.jar                               pom.xml
clojure-slim.jar                          doc                                       readme.txt
vvshs-macbook-2:clojure vvsh$ 

I got the same error on clojure 1.1 and lein repl(it seems lein maintain its own version of clojure).

By the way, this is on mac ox 10.5.8

java version "1.5.0_24"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_24-b02-357-9M3165)
Java HotSpot(TM) Client VM (build 1.5.0_24-149, mixed mode, sharing)

Anybody know what's wrong and how to fix it? As I really want to get lein repl working to start a project.

+1  A: 

see my alternative instructions for install on my fork:

http://github.com/jedschneider/leiningen

I sent a pull request to update the readme, but didn't get a response on it. once you have lein installed, you can put the bin/leiningen.sh in your ~/bin and call it anywhere. i put a shortcut on my .bash_profile

alias lein="~/bin/leiningen.sh"

and then call lein repl to launch a shell

also checkout the labrepl which is a great learning tool.

http://github.com/relevance/labrepl

Jed Schneider
Thanks for the good tool, I got the lein repl working by using pyrtsa's method.
vito huang
A: 

Your java ... command looks fine, I'd double check if all the jars are where you think they should be (and that they are the jars you think they are, i.e. clojure.jar is actually the one you built locally and not some super-outdated one).

If you want to use Leiningen for lein repl, that's possible too. Note that it isn't accurate to say that it "maintains its own version of Clojure"; Leiningen is a build tool, used as part of a project-oriented workflow, and the separate Clojure jars are project-specific. To create a sample project to play around in, say lein new foo someplace convenient. Then you'll need to cd foo, get your Clojure & contrib jars with lein deps (the project.clj skeleton provided by lein new already contains entries for both) and start a REPL with lein repl.

Finally, you could use the new cljr project; it has a comprehensive README which should get you started in no time, and with it you'll be able to say cljr repl to get a Clojure REPL anywhere, without the need to create a "project".

Michał Marczyk
Ah, by the way, if you want a fresh build of Clojure, you might be better off going to http://build.clojure.org/ and getting a jar from there. And if you're starting with the language -- it's not apparent from the question whether you are or not, but if -- you should probably stick with 1.1.
Michał Marczyk
Thanks, I'm a beginner so I think all the features in 1.1 will be enough to learn:)
vito huang
+2  A: 

I solved the same problem today by removing a redundant jline*.jar from /Library/Java/Extensions, leaving just one jline installation in CLASSPATH.

Longer explanation: I was trying to build labrepl, which installs all its dependencies in subdirectory lib, but I had previously set up jline by copying the .jar file to /Library/Java/Extensions. Apparently, java.lang.ClassLoader couldn't handle two installations of jline, and as long as there were ones available in two places, the command line starting a Clojure REPL would fail finding the latter one of classes jline.ConsoleRunner and clojure.main, depending on the order they were given to the java command.

I hope this helps.

pyrtsa
Thanks, everything works now, i can't believe simple remove it solve the problem.
vito huang