On 1 Lug, 17:47, Brian Schlining <bschlin...@gmail.com> wrote: > > Where I struggle is with the practicalities of managing the classpath. > > From what I can tell, there is no way of modifying the classpath from > > a running Java/Clojure program (barring use of a custom classloader > > which sounds like deep magic). > > There's URLClassLoader for loading classes at runtime. Javadocs are > athttp://java.sun.com/javase/6/docs/api/java/net/URLClassLoader.html. There's > an old thread about using it > athttp://forums.sun.com/thread.jspa?threadID=300557&start=0&tstart=0
Using a classloader manually is sub-optimal because the rest of Clojure, which doesn't know anything about the user-created classloader, wouldn't use it to load classes; you'd have to use the reflection API yourself to manipulate them. I recently added to ABCL the possibility of modifying which classloader to use, and to add to it dynamically new paths/URLs. I suspect that doing the same for Clojure would be easy, if the points where it loads classes are few - and they probably are. > Groovy has a very elegant solution for adding dependencies (from Maven and > Ivy repos) to scripts. Seehttp://groovy.codehaus.org/Grapes+and+grab(). If > some astute Clojure hacker with far more time than I were to grok the grape > code and create a similar dependency engine for Clojure, well it would > greatly expand Clojure's use for scripting and likely solve many of the > issues you're finding with CLASSPATH That's really nice! > > Python doesn't have these issues because (a) conventionally, > > dependencies are installed into the site-packages directory which is > > on the standard sys.path - it appears to me that the JVM doesn't have > > such an "always available" install location, > > Actually there is such a thing. For most JRE's/JDK's drop the > 'always-available-jars' in JRE_HOME/lib/ext. On Mac's you would place them > in /Library/Java/Extensions. Keep in mind that this is generally discouraged > in favor of setting the classpath on a per-application basis. There's a reason for that being discouraged: if you install a new version of the JRE/JDK, you'll have to copy your jars there by hand. Since Java auto-updates itself, at least on Windows, that's quite dangerous. Typically Java applications for end users come with a launch script to set the classpath; perhaps a function to generate such a script from Clojure would solve the problem in most cases? Alessio -- 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