Loads a MIDlet from a suite's JAR.
String[] jars;
Class midletClass;
if (suite.getID() == -1) {
/*
* This is the internal suite, that has no JAR
*
* This is a workaround for loading external midlets
* from command line. The ID can be -1.
*/
jars = MIDPLauncher.getMidletSuitePath();
} else {
jars = midletSuiteStorage.
getMidletSuiteClassPath(suite.getID());
}
/* Use MIDletClassLoader to load the main midlet class. */
MIDletClassLoader midletClassLoader =
MIDPConfig.newMIDletClassLoader(jars);
midletClass = midletClassLoader.loadClass(className);
if (!MIDlet.class.isAssignableFrom(midletClass)) {
throw new InstantiationException("Class not a MIDlet");
}
return (MIDlet)midletClass.newInstance();