Karachi   ->   Sweden   ->   Karachi, again   ->   Dubai   ->   Bahrain   ->   Karachi, once more   ->   London and Leeds

Thursday, October 18, 2007

Programming Your Sony Ericsson Mobile Phone

My W610i doesn't have an OS, which could have made it a smart phone. However, it supports Java Micro Edition (aka J2ME), as do most of other phones in the market. When I thought of programming this phone, I was happy to know that I already had J2SE 6 in my PC.

Instead of downloading Sun's Java Wireless Toolkit, I recommend getting Sony Ericsson's SDK for Java ME, which includes device profiles for most of the SE phones as well as a nice Device Explorer.

Below is a quick start guide to writing your first J2ME program and deploying it on your Sony Ericsson mobile phone. But before that, I'd recommend you going through deploying a pre-written application as described here using Sony Ericsson Toolkit.

Your simplest Hello World! midlet would be as follows:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HelloMIDlet extends MIDlet {
private Display display;
private TextBox t = null;

public HelloMIDlet () {
display = Display.getDisplay(this);

public void startApp() {
t = new TextBox ("Hello ", "Howdy!", 256, 0);
display.setCurrent (t);

public void pauseApp() {

public void destroyApp(boolean unconditional) {

The toolkit comes with KToolbar, a tool preconfigured to build and test (using an emulator) your midlets. We must create a new project using KToolbar. Let's say you call the project "Greetings" and the MIDlet class name as "HelloMIDlet". By default, the Wireless toolkit will create a folder named "Greetings" under C:\SonyEricsson\JavaME_SDK_CLDC\PC_Emulation\WTK2\apps. You can browse to Greetings\src and create a HelloMIDlet.java file containing the source code shown above.

Now return to KToolbar and click "Build" button, followed by "Run" button for testing it on an emulator. Once done you can prepare a JAR for deployment on your real phone by going to Project -> Package -> Create Package. Once done, you can install the jad and the jar using the Device Explorer.

No comments:

Post a Comment