Develop first J2ME application using EclipseME

Introduction

J2ME is used to develope the applications to run on mobile devices. J2ME application uses Java compiler, WTK and obfuscator to preverify the classes, package into jad, jar files.

J2ME is similar to java application with some slight changes in the syntax. In J2ME  instead of main method, it contains a MIDlet class, which starts the application. Each J2ME application contains one MIDlet class.

Steps to develope J2ME application:
  • Create the J2ME project in the eclipse as File-->Project-->J2ME-->J2ME Midlet Suite.
    • We can see the project in the elipse and by default the project includes src for source files, res for any images or any other resource files, deploy for jar, jad files and projectname.jad file.
      • Create a MIDlet class by using EclipseME wizard, right click on the src/package and select New-->other-->J2ME--> J2ME Midlet. This generates the skeleton of source code.

      •  Mdlet life cycle contains the startApp(), pauseApp(), destroyApp() steps. When the application is executed by default startApp() method will call and when close the application destroyApp() method will be called. But when the constructor is not null type then it will be executed firstly. Bellow screen show the lifecycle of Midlet application.
      •  Add images in the res folder and incase of any user defined properties add to the JAD file by double click on th JAD file and select the "user defined" tab.
      • To run a midlet in the emulator, bring up the "Run" dialog from the "Run | Run ..." menu. Choose the "Wireless Toolkit Emulator" tab, and click the "New" button to define a new run profile. You can specify the class name of the MIDlet to run in the profile. Next, click the "Run" button.


      1 comment: