J2ME HELLOWORLD Small Test

Source: Internet
Author: User
Tags exit file size stub
T628 Price, bought a play, this "chicken" support Java expansion, so the first time to Http://developer.sonyericsson.com/site/global/home/p_ home.jsp Download the latest SDK (FILE size:42m), please note that the SDK description should indicate that support t628,eclipse and eclipseme are already good, the following should be installed:

1, install J2SE 1.4.2, and configure path and Classpath
2, install Semc_j2me_sdk_2_1_5.exe, after loading I did not do any configuration (including environment variable configuration)
3, extract eclipse, and then extract eclipseme into Eclipse's plugins directory
4, then configure Eclipseme (Figure 1)
5, create a jeme project, File/new/project.../j2me/j2me Midlet Suite
6, add Midlet,file/new/other in the project. /j2me/j2me Midlet
7, write code
8, in the Navigator of the project on the right button, the implementation of the right menu J2me/create Package
9, with the simulator (Figure 2) or via Bluetooth to the phone to perform

(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 of this generated file go
* Window-preferences-java-code Style-code Templates
*/

/**
* @author Libo
*
* TODO to change the template of this generated type comment go
* 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 void Initmidlet () {
String text;
Display=display.getdisplay (this);
Mainform=new Form ("about");
Stringitem=new Stringitem (null,null);
Text= "This is my first J2ME program!";
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 ();
}
}
}

}


-----------------------------------------
End of code


Tip: T628 only supports CLDC 1.0 and MIDP 1.0, in the new construction project, the platform chooses the Sony Ericsson J2ME SDK (WTK 1.0.4) Platform, if you choose the Sony Ericsson J2ME SDK (WTK 2.1) Platform, you can run on the emulator, but uploading to the T628 will prompt an invalid application.





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.