// First, load the midp natives.
try {
String n = System.getProperty("sun.midp.library.name", "midp");
// DEBUG: System.err.println("Loading DLL \"" + n + "\" ...");
System.loadLibrary(n);
} catch (UnsatisfiedLinkError err) {}
/**
* Path to MIDP working directory.
* Default is the property "sun.midp.home.path", the fallback is user.dir.
*/
String userdir = System.getProperty("user.dir", ".");
String home = System.getProperty("sun.midp.home.path", userdir);
String profile = System.getProperty("microedition.profiles");
if (profile == null)
System.setProperty("microedition.profiles", "MIDP-2.1");
if (!initMidpNativeStates(home)) {
throw new RuntimeException("MIDP native initialization failed");
}
/**
* Making the runtime believe that this is a trusted midlet suite.
* This is needed because in midp's code, security check is often done
* by checking the executing midlet suite's security token.
* See com.sun.midp.jump.installer.TrustedMIDletSuiteInfo for more
* information.
**/
final MIDletStateHandler handler = MIDletStateHandler.getMidletStateHandler();
MIDletSuite suite = handler.getMIDletSuite();
if (suite == null) {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
Class clazz = MIDletStateHandler.class;
Field midletSuiteField = clazz.getDeclaredField("midletSuite");
midletSuiteField.setAccessible(true);
midletSuiteField.set(handler, new TrustedMIDletSuiteInfo());
} catch (Exception e) { e.printStackTrace(); }
return null;
}
});
}