java.lang.SecurityException: MIDP lifecycle does not support system exit.
By: Henry
Usually the Midlets (J2ME programs) doesn't call System.exit(). MIDP applications differ from J2SE applications in the way they terminate. To terminate your MIDlet, you only need to call the MIDlet's notifyDestroyed() method. This signals the AMS that your MIDlet is done executing. The AMS destroys the MIDlet instance and all of its objects. The VM still executes, however.You want the VM to continue executing so other MIDlets can run. A call to System.exit() signals the VM to terminate. This behavior is undesirable in MIDP applications. Your applications should not terminate the VM; in fact, they can't. If your application calls System.exit(), a java.lang.SecurityException will always be thrown. You'll see a trace back that looks something like the following:
java.lang.SecurityException: MIDP
lifecycle does not support system exit.
at java.lang.Runtime.exit(+9)
at java.lang.System.exit(+7)
at
HelloWorld3$MyCommandListener.commandAction(+15)
at
javax.microedition.lcdui.Display$DisplayAccessor.
commandAction(+99)
at
com.sun.kvem.midp.lcdui.EmulEventHandler$EventLoop.run(+430)
There are two main reasons why a MIDlet should not shut down the VM. First, other applications may be running; terminating the VM would destroy them. Second, you never start up the VM; therefore, you should not shut it down. The AMS controls the VM. It starts it and terminates it when it detects it's not needed, or if it needs to manage system resources.
Archived Comments
1. In my Midlet class there is a constructor which instantiate an inner class. from the midlet a move
View Tutorial By: nicolas at 2011-11-12 21:35:58
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Code sample to Send SMS from a J2ME application.
Adding your own Application icon for your J2ME application (jar file)
Play a multimedia file in J2ME Program (Audio/Video) using MMAPI
Using HttpConnection in J2ME (Retrieve web content from a website to a phone)
Using HTTP vs UDP vs Socket in J2ME
RMSCookieConnector - Using Cookies in J2ME
Client Server in J2ME (Socket Programming sample)
Datagrams in J2ME (UDP Programming sample)
POST UTF-8 encoded data to the server in J2ME
Using alerts and tickers in J2ME
Using List to create a Menu and Menu items in J2ME
lists, forms, choices, gauges, text fields, text boxes in J2ME
Timer and TimerTask example in J2ME