J2ME HelloWorld small tapping knife

xiaoxiao2021-03-06  38

T628 has been cut off, bought a play, this "chicken" supports Java extension, so I first go to http://developer.sonyericsson.com/site/global/HOME/p_home.jsp Download the latest SDK (File Size: 42m), pay attention to the download, the SDK description should point out support T628, Eclipse and Eclipseme are early, the installation is installed: 1. Install J2SE 1.4.2, configure PATH and ClassPath2, installation SEMC_J2ME_SDK_2_1_5.exe, I didn't do any configuration (including environment variable configuration) 3, decompressed Eclipse, then extract Eclipseme into the plugins directory of Eclipse, then configure Eclipseme (see Figure 1) 5, create one JEME project, file / new / project ... / j2me / j2me midlet suite6, add MIDlet, file / new / other ../ j2me / j2me midlet7, write code 8, right-click on Navigator's project, execute Right click on J2ME / CREATE PACKAGE9 in the menu, use the simulator (Figure 2) or by Bluetooth to execute (Figure 1) (Figure 2) The code is as follows: --------------- ------------------------------------------- Import javax.microedition.lcdui. Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.lcdui.StringItem; import javax. MicroEDition.midlet.midlet; import javax.microedition.midlet.midletStateChangeException; / * * Created on 2005-1-10 * * Todo to change the Template for this g Enerated File Go To * Window - Preferences - Java - Code Style - Code Templates * /

/ ** * @author libo * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates * / public class Helloworld extends MIDlet implements CommandListener {private Display display; private Form mainForm Private stringItem StringItem; private command exitcommand = new command ("exit", command.exit, 1); / ** * * / public helloworld () {super (); // Todo auto-generated constructor stub}

/ * (Non-Javadoc) * @see javax.microedition.midlet.MIDlet # startApp () * / protected void startApp () throws MIDletStateChangeException {// TODO Auto-generated method stub initMIDlet (); display.setCurrent (mainForm); } Private voidin () {string text; display = display.getdisplay (this); mainform = new form ("About"); stringItem = new stringItem (null, null); Text = "This is my first J2ME programs ";! stringItem.setText (text); mainForm.append (stringItem); mainForm.addCommand (exitCommand); mainForm.setCommandListener (this);} / * (non-Javadoc) * @see javax.microedition.midlet.MIDlet #pauseapp () * / protected void pauseapp () {// Todo auto-generated method stub

}

/ * (Non-Javadoc) * @see javax.microedition.midlet.MIDlet # destroyApp (boolean) * / protected void destroyApp (boolean arg0) throws MIDletStateChangeException {// TODO Auto-generated method stub System.out.println ( "exit the application ");} public void commandAction (Command cmd, Displayable display) {if (cmd == exitCommand) {try {destroyApp (false); notifyDestroyed ();} catch (MIDletStateChangeException e) {e.printStackTrace ();} }

} ---------------------------------------- Code end tips: T628 only supports CLDC 1.0 and MIDP 1.0, when the new construction project, the platform selects Sony Ericsson J2ME SDK (WTK 1.0.4) Platform, if you select Sony Ericsson J2ME SDK (WTK 2.1) Platform, you can run on the simulator, but transfer to T628 Will prompt the invalid application.

转载请注明原文地址:https://www.9cbs.com/read-70637.html

New Post(0)