2009/6/26 C. Florian Ebeling <florian.ebel...@gmail.com>: > > Hi, > > I randomly get ClassNotFoundExceptions when I try to compile a file. > This is a paste from the repl: > > Clojure 1.0.0- > user=> (compile 'app.hello) > java.lang.RuntimeException: java.lang.ClassNotFoundException: > app.hello$exec__4 (NO_SOURCE_FILE:0) > user=> (compile 'app.hello) > app.hello > > I'm really fresh to Clojure, but that strikes me as very odd. I just > execute the same command twice. But no regularity, before that it > would fail for 20 or so time in a row.
I have no idea why it would be random, but perhaps "classes" is not in your class path? This works for me if I create directories called "app" and "classes" in my current directory, put your hello.clj into the "app" directory and then start clojure "." and "classes" in my class path. e.g. like: java -cp ".:classes:/path/to/clojure.jar" clojure.main > I'm running the MacPorts packaged version 1.0.0 of Clojure on OS X > 10.5.7. (With JLine support.) > > FWIW, this is the Hello World I try to run, probably still buggy as well. > > ;; file app/hello.clj: > (ns app.hello (:gen-class) > (:import java.io.BufferedReader) > (:import java.io.InputStreamReader)) > > (refer 'clojure.core) ;; not sure if this is necessary This is not necessary. First, you can use (refer-clojure) instead of (refer 'clojure.core). http://clojure.org/api#toc482 Second, you should use: (ns ... (:refer-clojure)) instead if you really need to. Third, as per http://clojure.org/api#toc397 this happens by default anyway. I think the only reason for using (refer-clojure ...) or (ns ... (:refer-clojure ...)) is if you want to do something like pull in everything except a few functions like: (ns ... (:refer-clojure :exclude (slurp load-file))) > (defn capture [command] > (let [process (.exec (Runtime/getRuntime) command) > input (BufferedReader. (InputStreamReader. (.getInputStream process)))] > (loop [line (.readLine input) output (list)] > (if (zero? line) > (reverse output) > (recur (.readline input) (cons line output)))))) -- Michael Wood <esiot...@gmail.com> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---