Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #3471
| From | "Thomas Kellerer" <thomas.kellerer@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: Dynamic classpath |
| Message-ID | <68d9soF2r6qjbU1@mid.individual.net> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <XWdUj.8408$ko5.5712@news-server.bigpond.net.au> |
| Date | 2011-04-27 15:45 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui,comp.l wizard of oz, 07.05.2008 10:41: > 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 > You will need to use a URLClassLoader to load the driver(s) The only problem is then doing the connection as the DriverManager will refuse to use a driver that was loaded by a different classloader. You have two options to resolve this: 1) use Connection.connect(String, Properties) directly (bypassing DriverManager) 2) create a wrapper class that pretends to be a driver but delegates everything to the real instance (loaded by your own classloader). I am using option 1) without any problems. Thomas --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Dynamic classpath "wizard of oz" <wizard.of.oz@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: Dynamic classpath "Thomas Kellerer" <thomas.kellerer@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: Dynamic classpath "wizard of oz" <wizard.of.oz@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: Dynamic classpath "Thomas Kellerer" <thomas.kellerer@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: Dynamic classpath "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: Dynamic classpath "Ian Shef" <ian.shef@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
Re: Dynamic classpath "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:45 +0000
csiph-web