tags:

views:

167

answers:

1

I'm following the examples from the book 'Programming Clojure', and I'm at page 17 to run (require 'example.introduction).

I have set clojure at ~/bin/clojure as follows

java -server \
     -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888 -cp ... clojure.lang.Repl

The -cp contains . (current directory). When I try it with clojure, I get the following error message.

Exception in thread "main" java.lang.ExceptionInInitializerError
        at clojure.lang.Repl.(Repl.java:23)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.MultiFn.(Ljava/lang/String;Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V (utils.clj:0)
        at clojure.lang.RT.(RT.java:290)
        ... 1 more
Caused by: java.lang.NoSuchMethodError: clojure.lang.MultiFn.(Ljava/lang/String;Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V (utils.clj:0)
        at clojure.lang.Compiler.eval(Compiler.java:4153)
        at clojure.lang.Compiler.load(Compiler.java:4470)
        at clojure.lang.RT.loadResourceScript(RT.java:327)
        at clojure.lang.RT.loadResourceScript(RT.java:316)
        at clojure.lang.RT.load(RT.java:406)
        at clojure.lang.RT.load(RT.java:376)
        at clojure.core$load__4557$fn__4559.invoke(core.clj:3427)
        at clojure.core$load__4557.doInvoke(core.clj:3426)
        at clojure.lang.RestFn.invoke(RestFn.java:413)
        at clojure.core$load_one__4520.invoke(core.clj:3271)
...
        at clojure.lang.RT.loadResourceScript(RT.java:327)
        at clojure.lang.RT.loadResourceScript(RT.java:312)
        at clojure.lang.RT.maybeLoadResourceScript(RT.java:308)
        at clojure.lang.RT.doInit(RT.java:430)
        at clojure.lang.RT.(RT.java:286)
        ... 1 more
Caused by: java.lang.NoSuchMethodError: clojure.lang.MultiFn.(Ljava/lang/String;Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V
        at clojure.contrib.duck_streams__init.load(Unknown Source)
        at clojure.contrib.duck_streams__init.(Unknown Source)
...
        at clojure.lang.Compiler.eval(Compiler.java:4142)
        ... 28 more

I tried to run clojure as follows.

alias clojure='java -jar $JARDIR/clojure.jar ' 

But it doesn't have the CLASSPATH that I setup in .bashrc correctly, when I run the command as follows.

(println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))

What might be wrong?

+1  A: 

The easiest way is to use Stuart Halloway's code that accompanies the book:

  1. Clone Stu's code from GitHub: $ git clone http://github.com/stuarthalloway/programming-clojure.git
  2. cd into the programming-clojure directory that was created: $ cd programming-clojure
  3. Run the repl.sh script in the bin/ directory: $ ./bin/repl.sh (make sure you run it from the repo root, not the bin/ directory, otherwise it won't work).

The script will set up all the necessary paths, including the paths to the examples in the book.

(You can do it manually, of course, but at any rate, you have to download or clone the programming-clojure source code anyway for the examples to work.)

mipadi