Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.exit()------question?

 
China GuiLin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
{
System.exit(0);
}
}

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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 http://j2mecertificate.com exam simulator, including mock questions you
can have a go at. Other resources are listed in http://faq.javaranch.com/view?ScmadLinks

Regards,
[ November 09, 2006: Message edited by: Eduardo Marques ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic