Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ClassLoader to load external JARs into Eclipse RCP app at runtime
ClassLoader to load external JARs into Eclipse RCP app at runtime [message #659962] Wed, 16 March 2011 11:44 Go to next message
DK  is currently offline DK Friend
Messages: 16
Registered: June 2010
Junior Member
Hi,

I need to load about 5 JARs at runtime into my RCP app.

For licensing reasons I cannot bundle these Thirdparty JARs with my RCP app.

I tried using URLClassLoader which works nicely in a standalone Java program but doesn't work inside RCP because the way plugin class loading works.

I can't manage to get the steps here to work.
http://www.eclipsezone.com/eclipse/forums/t61831.html

Anyone have any useful links, code I could try?

Re: ClassLoader to load external JARs into Eclipse RCP app at runtime [message #659989 is a reply to message #659962] Wed, 16 March 2011 13:50 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

you could provide empty bundles for the needed jars with a MANIFEST.MF
that contains bundle entries like:
Bundle-ClassPath: external:$THIRD_PARTY_LIB$/lib/useful.jar

As part of your RCP install you can add -DTHIRD_PARTY_LIB=/useful/path
to your <rcp>.ini file (or feed it into the .ini some way) so the client
can fill in the local location of the libs you can't distribute.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
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


Re: ClassLoader to load external JARs into Eclipse RCP app at runtime [message #660021 is a reply to message #659989] Wed, 16 March 2011 14:57 Go to previous messageGo to next message
DK  is currently offline DK Friend
Messages: 16
Registered: June 2010
Junior Member
Any way to load the JARs up at runtime. i.e. Let user define the path to the JARs in a preference page and then load them up in my app?

[Updated on: Wed, 16 March 2011 14:57]

Report message to a moderator

Re: ClassLoader to load external JARs into Eclipse RCP app at runtime [message #660089 is a reply to message #660021] Wed, 16 March 2011 18:31 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 03/16/2011 10:57 AM, DK wrote:
> Any any to load the JARs up at runtime. i.e. Let user define the path to
> the JARs in a preference page and them load them up in my app?

And how will you use them? You can still load them using a
URLClassLoader in your bundle that understands the pref page and
instantiate classes from that, using the standard ClassLoader API.

What you can't do is simply load them into the global classpath. You
have to understand exactly who needs to see your classes and who needs
to use them (and how they use them) and then in an OSGi based app you
have a couple of choices for 3rd party jars that know nothing of OSGi:

1) if you can contain their use, simply have your bundle load them
through URLClassLoader.

2) you can create bundles on the fly that point to the jars and then
dynamically load them as you would any bundle, using the BundleContext.
The generated MANIFEST.MF will control who can see what.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
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


Re: ClassLoader to load external JARs into Eclipse RCP app at runtime [message #898131 is a reply to message #659989] Wed, 25 July 2012 21:04 Go to previous message
asm2008 asm2008 is currently offline asm2008 asm2008Friend
Messages: 5
Registered: July 2012
Junior Member
Paul Webster,
can i have your help? please check this link.
http://www.eclipse.org/forums/index.php/t/368193/
I got class resolve error, what i missed?

thanks a lot.
Previous Topic:what is this yellow popup window in the editor called
Next Topic:Associating rcp exe with "this kind of file"
Goto Forum:
  


Current Time: Thu Dec 18 21:12:38 GMT 2014

Powered by FUDForum. Page generated in 0.01705 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software