by Casper Bang <casper@[EMAIL PROTECTED]
>
May 8, 2008 at 09:37 PM
wizard of oz wrote:
> I have a need to have a classpath that is determined by the set of jars
> a user places into a directory.
>
> By way of example, placing jar's into certain directories in a tomcat
> web server will cause tomcat to include them into the web applications
> class path. An example of this might be a charting package used by the
> web app to generate charts.
>
> In my specific example, I am building a query tool and I want to be able
> to tell users to simply drop the JDBC drivers into a directory and my
> app will "pick them up". Thus there would be no need to edit the
classpath.
>
> My target environment is Java 6.0
>
> TIA
Now I may not understand completely, but isn't the simplest to just use
the service provider pattern, for which there was added direct support
for in Java 1.4.2. I've used this approach a lot, and like to think of
it as a form of dependency injection, obtained through the class path:
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider
/Casper