
startApp destroyApppauseAppstartApp method will contain the main
logic of your program. Following is an example:
package org.sunspotworld.demo;import com.sun.spot.sensorboard.EDemoBoard;import com.sun.spot.sensorboard.peripheral.ITriColorLED;import com.sun.spot.sensorboard.peripheral.LEDColor;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;public class HelloWorld extends MIDlet {private ITriColorLED leds[] = EDemoBoard.getInstance().getLEDs();protected void startApp() throws MIDletStateChangeException {System.out.println("Hello, world!");for (int i = 0; i < leds.length; i++) {leds[i].setColor(LEDColor.BLUE);leds[i].setOn();}}/*** This will never be called by the Squawk VM.*/protected void pauseApp() {// This will never be called by the Squawk VM}/*** Called if the MIDlet is terminated by the system.* I.e. if startApp throws any exception other than MIDletStateChangeException,* if the isolate running the MIDlet is killed with Isolate.exit(), or* if VM.stopVM() is called.** It is not called if MIDlet.notifyDestroyed() was called.** @param unconditional If true when this method is called, the MIDlet must* cleanup and release all resources. If false the MIDlet may throw* MIDletStateChangeException to indicate it does not want to be destroyed* at this time.*/protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {}}
ant jar-app - compile the
project and build a jarant info - display information
about the connected deviceant jar-deploy - deploy the
application to the connected SPOTant run - run the applicationant deploy - compile and deployant deploy run - compile,
deploy, and runISleepManager class
can be used to enable/disable deep-sleep mode.Date: 2008-03-27