Search code examples
clojurejline

clojure/lein REPL with jline


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.


Solution

  • 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.