Load a class at runtime [message #309287] |
Mon, 23 October 2006 08:40  |
Eclipse User |
|
|
|
Originally posted by: samuel.braun.ntb.ch
Hello
I have the following problem:
In my Eclipse plugin I want to load a class with Class.forName(...) at
runtime. The class which should be loaded is part of another plugin. I
always get the ClassNotFoundException back. I can't add the plugin (which I
want to load the class from) into the required plugins list of the plugin
which should load the class, because the plugin which I want to load the
class from requires the plugin which should load the class and then a cycle.
I also tried to load the class via an URLClassLoader but without success, I
think I do something wrong...
How can I get this to work?
Thanks in advance
Samuel
|
|
|
|
|
Re: Load a class at runtime [message #309296 is a reply to message #309287] |
Mon, 23 October 2006 13:40  |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"Samuel Braun" <samuel.braun@ntb.ch> wrote in message
news:ehid86$6po$1@utils.eclipse.org...
> Hello
>
> I have the following problem:
> In my Eclipse plugin I want to load a class with Class.forName(...) at
> runtime. The class which should be loaded is part of another plugin. I
> always get the ClassNotFoundException back. I can't add the plugin (which
> I
> want to load the class from) into the required plugins list of the plugin
> which should load the class, because the plugin which I want to load the
> class from requires the plugin which should load the class and then a
> cycle.
> I also tried to load the class via an URLClassLoader but without success,
> I
> think I do something wrong...
>
> How can I get this to work?
Tom's suggestion may be appropriate depending on the specifics of your case.
But in general, if plugin B depends on plugin A, and plugin A wants to load
a class from plugin B, the way it is done is with extension points. That
is, A exposes an extension point; B declares that it extends that extension
point; and then at runtime A uses the plugin registry to create the class
from B.
The method call to look at is
IConfigurationElement.createExecutableExtension().
|
|
|
Powered by
FUDForum. Page generated in 0.02872 seconds