Friday, September 4, 2009

Quick Start to J2ME

This is my first blog post about J2ME(Java2 Micro Edition. This blog is meant for novice readers who come from other mobile apps. background and willing to learn J2ME application development.

J2ME is widely used application development platform for mobile handsets and supported by most handset vendors. Hence it is a best suited platform for independent application developers.

In this post, I will be giving pointers to existing sources on the internet with an organized method to learn the application design & development.

Links/books for J2ME:
1. Java Complete reference to get an overview of Java
2. J2ME complete reference - good book to start off with simple applications
3. Refer Sun websites for all softwares and tutorials : http://www.sun.com/
4. Get sample codes/tutorial from codeguru.com , www.javaworld.com etc
5. Search for sample applications on the net

Recommended tools for application development/debugging/testing:
1. Java SDK(includes JDK & JRE) > v1.4
2. Eclipse IDE : http://www.eclipse.org/downloads/
3. MySql DB, JDBC for database connectivity : http://dev.mysql.com/downloads/
4. Tomcat Server: http://tomcat.apache.org/download-55.cgi
5. Sun Wireless toolkit for J2ME apps: http://java.sun.com/products/sjwtoolkit/download-2_5_1.html
6. EclipseME for mobile Apps(Clearly explains how to install, configuring with other tools and creating ur first app. ) : http://eclipseme.org/

Use the above configuration to write and execute your first J2ME application "Hello World". Below is the sample code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HelloWorld extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tbox;

public HelloWorld() {
exitCommand = new Command("Exit", Command.EXIT, 1);
tbox = new TextBox("Hello world MIDlet", "Hello World!", 25, 0);
tbox.addCommand(exitCommand);
tbox.setCommandListener(this);
}

protected void startApp() {
Display.getDisplay(this).setCurrent(tbox);
}

protected void pauseApp() {}
protected void destroyApp(boolean bool) {}

public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}

No comments:

Post a Comment