Slide 3.5: MIDlet
  Slide 3.7: The hello-world MIDlet
  Home


Using J2ME

  1. Download Sun Java Wireless Toolkit 2.3 Beta .

  2. Run KToolbar by selecting Start > Programs > Sun Java Wireless Toolkit 2.3 Beta > KToolbar.


  3. Create a new project, for example, named TinySuite with a class named TinyMIDlet.


    Click on OK after selecting settings for the project “TinySuite.” Note that this interface is only displayed once for a new project.


    The KToolbar will display the following message.



  4. Create a J2ME source file and put it in the example directory C:\WTK23\apps\TinySuite\src\, for example:

     C:\WTK23\apps\TinySuite\src\TinyMIDlet.java 
    
    // This package defines MIDP applications and the interactions
    // between the application and the environment in which the
    // application runs.
    import  javax.microedition.midlet.*;
    
    // This package provides a set of features for implementation
    // of user interfaces.
    import  javax.microedition.lcdui.*;
     
    public class  TinyMIDlet 
        extends  MIDlet 
        implements  CommandListener {
     
      public void  startApp( ) { 
        Display  display     = Display.getDisplay( this ); 
        Form     mainForm = new Form( "TinyMIDlet" ); 
      
        mainForm.append( "Welcome to the world of MIDlets!" ); 
        Command exitCommand = new Command( "Exit", Command.EXIT, 0 ); 
        mainForm.addCommand( exitCommand ); 
        mainForm.setCommandListener( this ); 
        display.setCurrent( mainForm ); 
      } 
       
      public void  pauseApp ( ) { } 
       
      public void  destroyApp( boolean unconditional ) { } 
       
      public void  commandAction( Command c, Displayable s ) { 
        if ( c.getCommandType( ) == Command.EXIT ) 
          notifyDestroyed( );
      } 
    }
    
    

    For how to create Mobile Information Device Profile (MIDP) applications with the J2ME Wireless Toolkit, check J2ME Documentation.

  5. Build the project by clicking on the Build button. The Build includes compilation and preverifying.


  6. Run the project by clicking on the Run button.

    Click on Launch ——>



    <—— Click on Exit


  7. Upload the application to handheld devices.


    To display more than one project on the emulator, specify all the class names.


    Modify the KToolbar —> Settings —> MIDlets, for example,


    After build and run the projects, the emulaotr will display them as follows: