Slide 7.e: Java ME (Java Platform, Micro Edition)
Slide 8.a: Lisp
Home

Using Java ME (Java Platform, Micro Edition)

  1. Download Java Platform Micro, Edition Software Development Kit (SDK) 3.0 .

  2. Run Java ME SDK by selecting
       Start ⇒ Programs ⇒ Java ME Platform SDK 3.0
             ⇒ Java ME Platform SDK 3.0

  3. Create a new project by selecting an MIDP application:


    Pick a project name such as Ex1 and location such as C:\Java ME\:


    Select the default platform:



  4. Default HelloMIDlet.java is displayed on the window:


    You may check the result of the HelloMIDlet.java by selecting Run ⇒ Build:


    and Run ⇒ Run:






  5. Create your own project by performing the following tasks, for example:
    1. In the directory C:\Java ME\JavaMESDKProjects\Ex1\nbproject, change the following line in the file project from
         manifest.midlets=MIDlet-1: HelloMIDlet, , hello.HelloMIDlet\n
                                         
         manifest.midlets=MIDlet-1: PacerMIDlet, , pacer.PacerMIDlet\n
    2. In the directory C:\Java ME\JavaMESDKProjects\Ex1\src, change the directory name from
         hello ⇒ pacer
    3. In the directory C:\Java ME\JavaMESDKProjects\Ex1\src\pacer, change the file name from
         HelloMIDlet.java ⇒ PacerMIDlet.java
    4. Write your own program by modifying the program PacerMIDlet.java as follows, for example:

        C:\Java ME\JavaMESDKProjects\Ex1\src\pacer\PacerMIDlet.java  
       package pacer;
      
       import  javax.microedition.midlet.*;
       import  javax.microedition.lcdui.*;
      
       public class  PacerMIDlet
          extends  MIDlet  implements  CommandListener {
      
         private Command  exitCommand;       // The exit command
         private Display  display;           // The display for this MIDlet
      
         public PacerMIDlet( ) {
           display = Display.getDisplay( this );
           exitCommand = new Command( "Exit", Command.EXIT, 0 );
         }
         public void startApp( ) {
           Displayable  d = new PacerCanvas( );
      
           d.addCommand( new Command( "Exit", Command.EXIT, 0 ) );
           d.setCommandListener( new CommandListener( ) {
               public void commandAction( Command c, Displayable s ) {
                 notifyDestroyed( );
               }
             }
           );
      
           Display.getDisplay( this ).setCurrent( d );
         }
         public void  pauseApp( ) {
         }
      
         public void  destroyApp( boolean unconditional ) {
         }
      
         public void  commandAction( Command c, Displayable s ) {
           if ( c == exitCommand ) {
             destroyApp( false );
             notifyDestroyed( );
           }
         }
       }
       class  PacerCanvas extends  Canvas {
         public void  paint( Graphics g ) {
           int  w = getWidth( );
           int  h = getHeight( );
      
           g.setColor( 0xffffff );
           g.fillRect( 0, 0, w, h );
           g.setColor( 0x000000 );
      
           for ( int x = 0; x < w; x += 10 )
             g.drawLine( 0, w - x, x, 0 );
      
           int z = 50;
           g.drawRect( z, z, 20, 20 );
           z += 20;
           g.fillRoundRect( z, z, 20, 20, 5, 5 );
           z += 20;
           g.drawArc( z, z, 20, 20, 0, 360 );
         }
       }

      For how to create Mobile Information Device Profile (MIDP) applications with the Java ME SDK, check Java ME Documentation.

  6. Rebuild and run the project: