Hi all,
I've been looking around on the net for a tutorial on how to create a plugin discovery system for a java program.
I am trying to follow the example found at What is Java Reflection? | JAVA Developer's Journal
I have a simple class which implements my plugin interface.
I then want to load that plugin and be able to call those methods having dynamically loaded that class in another program.Code:public class Main implements IXactPlugin
{
String name = "Plugin1";
public static void main(String[] args)
{
System.out.println("Here");
Main moo = new Main();
}
public Main()
{
process();
System.out.println(getName());
System.out.println(methods()[0].getName());
}
public void process()
{
System.out.println("Process");
}
public String getName()
{
return name;
}
public Method[] methods()
{
Method m[] = null;
try
{
Class c = Class.forName(this.getClass().getName());
m = c.getDeclaredMethods();
}
catch (Throwable e)
{
System.err.println(e);
}
return m;
}
}
Here is the code I have for the plugin loader
Problem I am having is the lineCode:File folder = new File("C:/Users/Ash/Documents/NetBeansProjects/PluginFramework/plugins");
File[] listOfFiles = folder.listFiles();
for ( int i = 0; i < plugInNames.length; i++ )
{
MyApplicationPlugIn plugIn = (MyApplicationPlugIn)Class.classFor( plugInNames[i] );
}
It cant find the classFor method.Code:MyApplicationPlugIn plugIn = (MyApplicationPlugIn)Class.classFor( plugInNames[i] );
Any help would be greatly appreciated.
Kind Regards
Ash

