Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » runtime jar loading
runtime jar loading [message #535920] Wed, 26 May 2010 06:57 Go to next message
Sebastian is currently offline Sebastian
Messages: 26
Registered: July 2009
Junior Member
Hi,

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")).

Thank you very much
Sebastian
Re: runtime jar loading [message #535925 is a reply to message #535920] Wed, 26 May 2010 07:06 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael Istria
Messages: 745
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

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.

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: runtime jar loading [message #535927 is a reply to message #535925] Wed, 26 May 2010 07:12 Go to previous messageGo to next message
Sebastian is currently offline Sebastian
Messages: 26
Registered: July 2009
Junior Member
Am 26.05.2010 13:06, schrieb Mickael Istria:
> Hi,
>
> 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.
>
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php

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?
Re: runtime jar loading [message #535954 is a reply to message #535927] Wed, 26 May 2010 09:15 Go to previous message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

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
the classes.

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.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:OpenGL rendering to an SWT Image
Next Topic:how to remove the "Run" actionset from menu?
Goto Forum:
  


Current Time: Sat Aug 30 00:24:38 EDT 2014

Powered by FUDForum. Page generated in 0.01676 seconds