to help with the temptation i wrote a little ruby script which configures java classpaths and invokes clojure [only tried on macos... probably fine on linux, and should be portable to windows]
http://github.com/mccraigmccraig/clojure-load.rb if you put all your clojure project repos, including clojure-load.rb, in one directory you can invoke it so : clojure -l clojure-json clojure and clojure-contrib are loaded by default at the end of the classpath. if a repo doesn't follow the conventional layout, or you need more control, you can specify the classpath order and add dirs of jars or individual jars or dirs. e.g. clojure -l clojure -l clojure-contrib -p compojure/classes -p compojure/src -j compojure/deps and you can give arbitrary jvm args or script args without setting environment vars, using the -- separator : clojure --script -l clojure-json -- -Xmx1g -- script/path args ruby is another dependency : i just couldn't face doing it in bash :) c On 27 Jun 2009, at 07:34, Laurent PETIT wrote: > > While I'm far from a java classpath-related issues problem, I think I > know enough to say that placing your libs in the java.ext.dirs > classpath is a trick that could lead to problems. > > It's primary and sole intent is to hold extensions to the java API > that then would be loaded with the core java APIs. > That's certainly why you're having problems when you mess up the > dependencies in places where there is a hierarchy of classloaders > involved : clojure-contrib was loaded with the "main classloader" > along with java core libraries, and clojure was loaded with a "child" > classloader. And thus clojure-contrib classes were not able to see any > of the classes in the child classloader. > > The problem with this java.ext.dirs is of the category of problems > pointed out by C. Martin (and others!) as a design smell : the one > named "viscosity" : "doing things right is harder than doing things > wrong". It's so easy to put everything in this java.ext.dirs directory > that it's difficult resisting the temptation ! > > Regards, > > -- > Laurent > > 2009/6/27 Chouser <chou...@gmail.com>: >> When I starting Clojure, I generally point -Djava.ext.dirs >> at a "classpaths" directory. That's where I dump jars, >> symlinks to jars, and symlinks to the 'src' and 'classes' >> directories of the various projects I have installed. >> >> I know that some people have had trouble with java.ext.dirs >> and instead use wildcards in their classpaths or other more >> complicated solutions. But since I've never seen these >> problems described in enough detail to reproduce or >> troubleshoot, when I stumbled on one tonight I thought it'd >> be worth documenting... >> >> Here is the simplest way I've found to produce the error I'm >> seeing: >> >> 1. Compile clojure-contrib >> 2. Create a "classpaths" directory with symlink to >> clojure-contrib/classes, so as to add the compiled contrib >> classes to the classpath. Mine lookes like this: >> >> $ ls -l classpaths/ >> total 0 >> lrwxrwxrwx 1 chouser chouser 32 2009-06-27 00:54 classes -> >> ../proj/clojure-contrib/classes/ >> >> 3. Start clojure and try to use something from contrib: >> >> java -Djava.ext.dirs=classpaths -cp proj/clojure/clojure.jar >> clojure.main >> user=> (require 'clojure.contrib.math) >> java.lang.NoClassDefFoundError: clojure/lang/RT (NO_SOURCE_FILE:0) >> >> The full stack trace for that exception is attached. >> >> >> I've found two workarounds so far. Take your pick: >> >> A. Add clojure.jar to the "classpaths" directory. Once >> that's done, it doesn't matter if you also specify it in -cp >> on the java command line or not: >> >> $ ls -l classpaths/ >> total 0 >> lrwxrwxrwx 1 chouser chouser 32 2009-06-27 00:54 classes -> >> ../proj/clojure-contrib/classes/ >> lrwxrwxrwx 1 chouser chouser 27 2009-06-27 01:06 clojure.jar -> >> ../proj/clojure/clojure.jar >> >> B. Remove the contrib link from "classpaths" and specify it >> on the java command line instead: >> >> java -Djava.ext.dirs=classpaths -cp proj/clojure-contrib/classes >> clojure.main >> >> --Chouser >> >>> >> > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---