Optimize J2ME program Size

Source: Internet
Author: User

The

to distinguish J2ME programs from J2SE programs is based on the restricted environment in which J2ME runs. The main limiting condition for most J2ME systems is the size of the memory needed to store and run the program. For example, many MIDP devices limit the size of the application to 50K, which is far less than the megabytes in the server-side J2SE operating environment. In practical applications, programs can easily go beyond these limits. In this article you will learn some techniques to reduce the size of your program and practice these techniques in the following examples. This example MIDlet only displays a text box and sounds when its contents change.

Package com.j2medeveloper.techtips
Import javax.microedition.lcdui.*;
public class Beforesizeoptimization extends
Basicmidlet {
public static final Command exitcommand =
New Command ("Exit",
Command.exit, 1);
Public beforesizeoptimization () {
}
protected void Initmidlet () {
Getdisplay (). Setcurrent (New MainForm ( ) );
}
public class MainForm extends form {
Public mainform () {
Super ("MainForm");
AddCommand (Exitcomman D);
Append (TEXTF);
Setcommandlistener (New Commandlistener () {
public void commandaction (Command c,
displayable d) {
if (c = = Exitcommand) {
Exitmidlet ();
}
}
}
);
Setitemstatelistener (
New Itemstatelistener () {
public void itemstatechanged (
Item Item) {
if (item = = TEXTF) {
AlertType.INFO.playSound (
Getdisplay ());
}
}
}
);
}
Private TextField TEXTF =
New TextField ("Type anything", NULL,
0);
}
}

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.