Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clojure/lein REPL with jline

Tags:

clojure

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.

like image 703
vito huang Avatar asked Jul 10 '10 11:07

vito huang


2 Answers

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.

like image 148
Pyry Jahkola Avatar answered Sep 22 '22 10:09

Pyry Jahkola


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

like image 40
Jed Schneider Avatar answered Sep 23 '22 10:09

Jed Schneider