Help dynamically loading Java that requires a framework
Help dynamically loading Java that requires a framework
- Subject: Help dynamically loading Java that requires a framework
- From: Barry Wark <email@hidden>
- Date: Thu, 18 Apr 2002 15:44:31 -0700
I'm writing a Cocoa-Java application and would like to use bundles to store
application plugins. Each plugin is a single Java class and one or more
frameworks which contain code used by that class (the plug-in class extends
one of the classes in the framework). The plugin is listed as the
principalClass of the bundle (created using "Add target..." in the
application's project). Since the frameworks used by the plugins are also
used by the main application, I've added a "Copy files" build phase to the
main application and copied these frameworks into the main application's
"Frameworks" directory. In the targets for the plugins, I've added the
necessary frameworks, but do not copy them into the plugin's bundle.
I'm attempting to load the plugin's class with:
NSBundle pluginBundle = NSBundle.bundleForPath([path_to_bundle] );
Class pluginClass;
Object pluginObj;
if(pluginBundle == null) {
//error
}
pluginClass = pluginBundle.principalClass();
if(pluginClass == null) {
//error
try {
pluginObj = pluginClass.newInstance();
} catch (InstantiationException e) {
//error;
} catch (IllegalAccessException e) {
//error;
}
This works fine on a "dummy" plugin, which does not use any of the
frameworks mentioned above (the principal class of the bundle is an empty
extension of java.lang.Object). When I attempt to use a bundle which
contains a principal class that extends a class in the framework, and whose
target includes the framework, the Java class loader throws a
ClassNotFoundException. So I think the problem is trying to load a class
that depends on a framework which is either in the main application's bundle
or in the plugin's bundle.
Copying the frameworks into the plugins bundle does not seem to remedy this
problem.
Can anyone shed some light on what I've done wrong?
Thanks!
barry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.