>> 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?

nah, with the paste from the repl I intended to demonstrate that it
worked and didn't work in two succesive invocations of the exact same
compile form. I didn't change anything in the environment. I think
that it worked in one instance effectively excludes something being
wrong with the classpath.


> 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

that is my classpath setup as well. I don't think there is the problem.

>> ;; 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)))

Thanks for this dicussion of my code. I really appreciate feedback
here, since I'm very new to Clojure. I will read up on the alternative
options you mentioned here.

Florian



-- 
Florian Ebeling
Twitter: febeling
florian.ebel...@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to