Java Reference
In-Depth Information
L ISTING 6.2 Continued
6
Object[] arg = new Object[paramNumber];
Class[] param = cons.getParameterTypes();
for (int i = 0; i < paramNumber ; i++) {
//for each parameter, initializes it using its default constructor
arg[i] = param[i].newInstance();
}
cons.newInstance(arg);
System.out.println(“ApplicationHelper- appl. launched creating:
“+cons);
} catch (Exception exc){
launched = false;
}
}
return launched;
}
/**
* This method launches the whole application
*
*/
public void launch() {
boolean successfullyLaunched = false;
loader = new BankClientLoader(this);
try {
Class mainClass =
loader.loadClass(launchClassName, loader.getClass(launchClassName));
// first, try to use the main() method
successfullyLaunched = mainMethodLaunch(mainClass);
// if not present, try to create an instance
if (!successfullyLaunched)
successfullyLaunched = creationLaunch(mainClass);
if (!successfullyLaunched)
System.out.println(“ApplicationHelper- unable to launch application.”);
// after launched class finished, exit application
shutDown();
} catch (Exception e) {
System.out.println(“ApplicationHelper- Launch Failed. “+e);
e.printStackTrace();
}
Search WWH ::




Custom Search