That out of the way, lets rock on with the main business! Newcomers to J2ME should start by looking at the Introduction and Installation of the software tools that we will be using throughout our articles on J2ME Mobile development. The introduction page will give you a firm understanding of what J2ME is and what it isn't. If you also want to know how to configure your web server to allow you to serve your J2ME applications from your server, have a look here. Please note that the configuration described here is for web servers running Apache 2, and if anyone knows how to do it on Windows platform, please email me. Once you have the basics of what J2ME is, the next step will be to role your sleeves up and start designing, coding and experimenting with small projects. So, to follow this section properly, I would expect that you have gone through the introduction section as suggested above and you have all the tools ready to start coding. Here are the steps we will go through here:
- writing our first 'Hello World' application
- compilling
- deploying
- distribute your application
package com.onyxtic;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener
{
private Form form;
public HelloWorld (){
form = new Form ("HelloWorld");
form.append (new StringItem (null, "Hello world from Onyxtic!"));
form.addCommand (new Command ("Exit", Command.EXIT, 0));
form.setCommandListener (this);
}
public void startApp (){
Display.getDisplay (this).setCurrent (form);
}
public void pauseApp (){
}
public void destroyApp (boolean unconditional){
}
public void commandAction (Command c, Displayable s){
notifyDestroyed ();
}
}
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener
{
private Form form;
public HelloWorld (){
form = new Form ("HelloWorld");
form.append (new StringItem (null, "Hello world from Onyxtic!"));
form.addCommand (new Command ("Exit", Command.EXIT, 0));
form.setCommandListener (this);
}
public void startApp (){
Display.getDisplay (this).setCurrent (form);
}
public void pauseApp (){
}
public void destroyApp (boolean unconditional){
}
public void commandAction (Command c, Displayable s){
notifyDestroyed ();
}
}
Find out more about Me.