Okey, I will load classes with applet, I have c100.class, c101.class and so on class files, thei all contain one class as follows: public class <filename>{ // <filename> - wouldbe c100, c101 and so on public void function(char a[], char b[], int c, int d, int e[]){ //some code }; }
So I need dinamiclly loading one class at the time and I use code below, where name - is class name(c100, c101), and surl - path were classes are stored: public Class getClass(String name, String surl) { URL url = null; URLClassLoader ucl = null; try { url = new File(surl).toURL(); URL urls[] = new URL[] { url}; ucl = new URLClassLoader(urls); } catch (MalformedURLException ex) { } if (ucl != null) { try { return ucl.loadClass(name); } catch (ClassNotFoundException ex1) { return null; } } return null; }
So for now everything is fine, but now then I load class in lets say main function: void static main(){ Class myClass = getClass("c100", "some dir"); //here I need to call function(char[],char[],int,int,int[]); }
the problem is that I dont know how to call function. I have find out how to get that function: Method m = myClass.getMethods[0];
Is where any way to cast as somthing : Object object = myClass.newInstance(); object.getClassName() o = (object.getClassName())object; // and then calling function\ o.function(char[], char[], int, int, int[]);