• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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~!
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Your mind is under my control .... your will is now mine .... read this tiny ad
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic