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!
java.lang.SecurityException: Application not authorized to access the restricted API
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$
Any help would be appreciated. Thanks
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!