Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home J2me J2ME Hello World Example

Related Tutorials


 
 

Share on Google+Share on Google+

J2ME Hello World Example

Advertisement
This is the simple hello world application.

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

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 25, 2009

Related Tutorials

Discuss: J2ME Hello World Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:18
md
February 2, 2012
j2me

hello, could you please ,give me details i'm a bagginer , here are some questions : is it an obligation to put "notifyDestroyed()" , in the startApp() can we put Display.getDisplay(this).setcurrent(form) ; i know it's stupid as questions but just answer me please , thanx
imam
February 12, 2012
Compile

how to compile this j2me basic app and how to run this
K.ARUN PRAKASH
February 13, 2012
java

Good website for java developers
masum
February 26, 2012
love

Thank you!
venkat santosh
April 1, 2012
why did u use super(); in the constructor

why did u use super(); in the constructor?
Senobyte
August 23, 2012
Notes

First of all, thank you for providing a basic Java Micro Edition 'hello world' app. Even though the code is not explained line by line, one can get the idea. I found that using Eclipse, I could not just cut and paste the source, that would give errors. Rather, I generated the structure code automatically and filled the example code line by line. For some reason, that worked and it also helped me learn about what I think is going on with the code. Thanks again and greetings from the USA!
haftay
January 7, 2013
software engineering student

this is amazing note please continue and develop this as one book
satheesh
July 25, 2013
j2me

VERY GOOD .... HELPS ME VERY MUCH
mohamed Adam
October 17, 2013
jdk

dear Pawan, its very easy to create jar files, you must put all your files and use only CMD (the command prompt) and JDK ( java development kit)
DMCA.com