Home J2me J2ME Hello World Example
Questions:Ask|Latest


 
 

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

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

Ask Questions?    Discuss: J2ME Hello World Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
pawan
June 4, 2011
sir

how to make a jar file..??? pls can u help me..
bangaram
June 7, 2011
convert j2ee source code to j2me source code

hello world example is simple to understand. but how can I convert my j2ee(calculator by using swing concept) source code to j2me source code.
priya
July 6, 2011
opinion

hi sir, this program is very useful for us to start a j2me applications.,thank u sir,
Eshrath
June 3, 2013
J2me

iam getting near super(); can you help me.....
irfan
May 29, 2013
regarding jar file

how to create a jar file for this app. i got jad file in my bin folder but not jar file.please help me out. thank you for the help.
irfan
May 29, 2013
regarding jar file

please tell me how to create jar file for this app. i found jad file onlu for this app in my bin folder. i don't know how to create jar file. thanking you for the help
SRIKAR
September 8, 2011
Mobile Applications And Development

I Require This lab programes
Dinesh
October 9, 2011
j2me

What is use of super() in constructor?
Komba
November 5, 2011
Suggestion

It could be better if you give a little explanation about the methods in these codes and what they do for novice programmers like me because I can't really get what is happening in these codes as they are
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