Hi Yoshinori,
after (unsuccessfully) struggling with Clojure dynamic ClassLoaders in
clojure-1.4, I ended up with the 'brute force' solution--just add URL
entries to the Java system classloader. Here is a simple example on how to
do it from clojure:
(defn add-system-classpath
"Add an url path to the system class loader"
[url-string]
(let [field (aget (.getDeclaredFields java.net.URLClassLoader) 0)]
(.setAccessible field true)
(let [ucp (.get field (ClassLoader/getSystemClassLoader))]
(.addURL ucp (java.net.URL. url-string)))))
(add-system-classpath "file:/some/clojure/root/")
(load "some/clojure/file") ;; load the some/clojure/file.clj from the
/some/clojure/root/ catalog
(add-system-classpath "file:/some/java/classes/")
some.java.MyClass ;; use the some.java.MyClass in the /some/java/classes/
catalog
Regards,
Vladimir
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en