I am developing an rcp application which should access sql-databases.
how can I load jdbc-driver-jar-files at runtime, so that I can use them
within my rcp application (for Class.forName("classname")).
Mickael Istria Messages: 745 Registered: July 2009 Location: Grenoble, France
If your jar are available at build-time, you can use some nested jars in a bundle so that their class will be available from this bundle. (You'll have to populate Bundle-Classpath, build.properties and maybe Export-Packages).
Otherwise, you'll have to create your own classloader containing the jar and load classes from it.
Am 26.05.2010 13:06, schrieb Mickael Istria:
> If your jar are available at build-time, you can use some nested jars in
> a bundle so that their class will be available from this bundle. (You'll
> have to populate Bundle-Classpath, build.properties and maybe
> Otherwise, you'll have to create your own classloader containing the jar
> and load classes from it.
> Mickael Istria - BonitaSoft S.A.
thanks for the response.
the jars are not avaiable at runtime unfortunately. I have searched
already for creating classloaders and using them with rcp but I couldn't
find anything usefull. Do you jave any hints?
Paul Webster Messages: 6859 Registered: July 2009 Location: Ottawa
loading classes at runtime in OSGi works well if you dynamically add a
bundle through the framework. Also if you use Extension
Points/Extensions and IExecutableExtensions (cause the
IExtensionRegistry to load the class for you).
For a very narrow case, you can create a URLClassLoader and load a jar
.... but that wouldn't allow any other part of the system to see classes
from that jar, and would only allow you to use reflection to instantiate
I would have a look at http://wiki.eclipse.org/datatools They have and
SQL editor and a database explorer, I believe, so they must have solved
the "how do I load a JDBC driver and use it in OSGi bundles" problem.