Meaningless Drivel is fun!
The moose likes Product and Other Certifications and the fly likes System.exit()------question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "System.exit()------question?" Watch "System.exit()------question?" New topic


China GuiLin

Joined: Oct 15, 2006
Posts: 3
HI rancher;

MIDlet must not call the System.exit() method,if called,a SecurityException will be throw.

import javax.microedition.midlet.*;

public class MyMIDlet8 extends MIDlet

public void startApp() throws MIDletStateChangeException
System.out.println("Hello World");
public void pauseApp(){}
public void destroyApp(boolean unconditional)//throws MIDletStateChangeException

But this code will run without exception.why?
I am preparing for SCMAD,and get some ideas to me .
thank you~!
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
An exception is actually thrown if the device conforms to the MIDP specs.

However since this happens in the destroyApp() methods, maybe the WTK (or the device you're using) ignores it. Note that you don't need and should not use System.exit(0), particularly in the destroyApp() method. destroyApp() is called when the MIDlet is being destroyed ...

If you're interested in studying for SCMAD take a look at the exam simulator, including mock questions you
can have a go at. Other resources are listed in

[ November 09, 2006: Message edited by: Eduardo Marques ]

Eduardo Marques
Get ready for your SCMAD certification at - See what all the buzz is about ...
I agree. Here's the link:
subject: System.exit()------question?
It's not a secret anymore!