This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See java.lang.SecurityException: Application not authorized to access the restricted API at com.sun.midp.security.SecurityToken.checkIfPermissionAllowed(+40) at com.sun.midp.security.SecurityToken.checkIfPermissionAllowed(+7) at com.sun.midp.midletsuite.MIDletSuiteImpl.checkIfPermissionAllowed(+8) at com.sun.midp.midlet.MIDletState.<init>(+66) at javax.microedition.midlet.MIDletProxy.<init>(+5) at javax.microedition.midlet.MIDlet.<init>(+13) at subscribe.<init>(+4) at Traffic.commandAction(+38) at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+284) at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10) at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68) at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47) at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+250) Any help would be appreciated. Thanks
Hi So you are calling in one class new ClassName() and get that exception? That is very strange. What kind of class are you trying to instantiate? Perhaps you gave the class a forbidden package name like javax.microedition.XXX? Regards
From the stack trace, it seems like his method commandAction in class Traffic is trying to create a new instance of class 'subscribe', which extends MIDlet. In general, you may not create instances of classes extending MIDlet: that's the job of the phone's Java VM (actually, its application manager). If you try, you'll correctly get a security exception. Since this MIDlet subclass called 'subscribe' is not actually being used here as a MIDlet (i.e. a thing the user can run, managed by the application manager), move the functionality needed from it here into a separate non-MIDlet class, then create an instance of that instead.