Thanks, this clarifies why my initial tests setting the current class
loader failed.

On Thu, Dec 8, 2011 at 2:14 AM, Brent Millare <brent.mill...@gmail.com> wrote:
> To better understand what's going underneath, you're just calling the addURL
> method of the classloader. But since you might be evaluating this at the
> repl, there is an important point regarding the classloader. Everytime
> clojure evaluates a form, it will use a new classloader on that form, and
> the parent will be the classloader of the caller of the eval. So this means
> if you evaluate two forms consecutively, the first being the addURL, and the
> second, the command depending on the jar, the second will fail (unless you
> wrap both commands in a let). You need to ensure that the parent of the
> current classloader in the call to addURL is set. This way, all future evals
> will delegate to the classloader that knows about the jar.
>
> So in summary, the heart of the command should just be:
>
> (.addURL (.getContextClassLoader (Thread/currentThread)) (.toURL (.toURI
> file)))
>
> For runtime dependency management, pomegranate does this, and so does my
> library, dj https://github.com/bmillare/dj
>
> --
> 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

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