% cd /tmp
% svn co https://clojure.svn.sourceforge.net/svnroot/clojure/trunk
clojure > /dev/null
% svn co https://clojure-contrib.svn.sourceforge.net/svnroot/clojure-contrib/trunk
clojure-contrib > /dev/null
% cd clojure
% ant > /dev/null
% java -cp clojure.jar:/tmp/clojure-contrib/src:/tmp/myclasses
clojure.lang.Repl
Clojure
user=> (require 'clojure.contrib.except) ; same behavior
with or without this line, just showing that clojure.contrib is
accessible
nil
user=> (binding [*compile-path* "/tmp/myclasses"] (compile
'clojure.contrib.except))
java.lang.RuntimeException: java.lang.ClassNotFoundException:
clojure.contrib.except$throwf__35 (NO_SOURCE_FILE:0)
user=> (System/getProperty "java.class.path")
"clojure.jar:/tmp/clojure-contrib/src:/tmp/myclasses"
user=> (binding [*compile-path* "/tmp/myclasses"] (compile
'clojure.contrib.except))
java.lang.RuntimeException: java.lang.ClassNotFoundException:
clojure.contrib.except$throwf__44 (NO_SOURCE_FILE:0)
user=>
% ls -R /tmp/myclasses
clojure
/tmp/myclasses/clojure:
contrib
/tmp/myclasses/clojure/contrib:
except$throwf__35.class except$throwf__44.class except.class
% java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
The ClassNotFoundException is thrown even though it appears that the
class should be found. A class file with that name exists in the
(global) classpath. The example shown is Mac OS X Leopard. The failure
is exactly the same on Ubuntu 8.10 Linux with this java -version:
% java -version
java version "1.6.0_0"
IcedTea6 1.3.1 (6b12-0ubuntu6) Runtime Environment (build 1.6.0_0-b12)
OpenJDK Client VM (build 1.6.0_0-b12, mixed mode, sharing)
--Steve
The classes directory ("/tmp/myclasses" in this case) must exist
before you start Java with it in your classpath. You get no error at
this point, but apparently if the directory doesn't exist it's not
really used, even though it's shown in the java.class.parth property
string.
--Chouser
Thanks, that works great! It also explains why the ant build works--it
always creates the directory first.
Unless this changes, perhaps the Clojure AOT mechanism should refuse
to create the directory at *compile-path* and instead require that it
already exist. That would catch many instances of this problem and
could provide a helpful message.
Is there any way Clojure can add *compile-path* to classpath at the
correct level so it's recognized in all the places it needs to be? I
gather if that were easy, Rich would have already done it.
Any ideas?
--Steve