This page was last modified 04:15, 31 January 2008.
Hello World in Java ME
From Forum Nokia Wiki
If we want to learn a new language, the first program is always the classical "Hello World!"
This program creates a new form with a string item and an exit button.
To install the tools needed for developing in Java ME for Nokia devices, see articles Getting started with Java ME, Installing Java ME development tools for S60, and Creating your first MIDlet using EclipseME.
package com.example.helloworld; import javax.microedition.midlet.MIDlet; import javax.microedition.lcdui.*; public class HelloWorldMidlet extends MIDlet implements CommandListener { public HelloWorldMidlet() { } // Display private Display display; // Main form private Form form; // For the message private StringItem stringItem; // For the exit command private Command exitCommand; public void commandAction(Command command, Displayable displayable) { if (displayable == form) { if (command == exitCommand) { exitMIDlet(); } } } public void startApp() { // Create form stringItem = new StringItem("Hello", "Hello World!"); form = new Form(null, new Item[] {stringItem}); exitCommand = new Command("Exit", Command.EXIT, 1); form.addCommand(exitCommand); form.setCommandListener(this); // Get display for drawning display = Display.getDisplay(this); display.setCurrent(form); } // Your MIDlet should not call pauseApp(), only system will call this life-cycle method public void pauseApp() { } // Your MIDlet should not call destroyApp(), only system will call this life-cycle method public void destroyApp(boolean unconditional) { } public void exitMIDlet() { display.setCurrent(null); notifyDestroyed(); } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| General Guide to Downloading Games/Apps | chrigil | Mobile Java General | 3 | 2004-04-20 16:28 |
| S60 3rd edition SDK Emulator query | DanDanDan | Symbian Tools & SDKs | 10 | 2008-02-02 13:56 |
| Where to find good and cheap developers in the world? | shout2 | Mobile Java General | 1 | 2006-02-05 08:25 |
| Problem: Java.Security.SecureRandom does not exists | AyedSQ | Mobile Java Networking & Messaging & Security | 8 | 2006-10-04 21:52 |
| Java Instructor looking for J2ME help | stanlick | Mobile Java General | 2 | 2005-11-27 01:39 |

