J2ME Hello World Example

This is the simple hello world application.

J2ME Hello World Example

J2ME Hello World Example

     

This is the simple hello world application. In this example we are creating a form name "Hello World" and creating a string message "Hello World!!!!!!!" as below: 

Form form = new Form("Hello World");   

String msg = "Hello World!!!!!!!";

In this application, To display the message we are using append method with the form as below:

 form.append(msg);

 

 

The Application is as follows:

 

HelloWorld.java

 

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class HelloWorld extends MIDlet{
  private Form form;
  private Display display;

  public HelloWorld(){
  super();
  }

  public void startApp(){
  form = new Form("Hello World");
  String msg = "Hello World!!!!!!!";
  form.append(msg);
  display = Display.getDisplay(this);
  display.setCurrent(form);
  }

  public void pauseApp(){}
  
  public void destroyApp(boolean unconditional){
  notifyDestroyed();
  }
}

 

Download Source Code