So this is my example of creating a J2ME application using the EclipseME plugin.
This example should work on similar Sony Ericsson phones.
Prerequisites
You need to have the following installed before doing anything else:
- JDK 6
- Eclipse 3.2 or above
- A Sony Ericsson phone with a USB or bluetooth connection
- Sony Ericsson PC Suite (this should have come on a cd with your phone too)
Next you will need to install the EclipseME plugin to Eclipse
- Follow the install instructions from here.
- After you have restarted Eclipse ,you will need to configure EclipseME with Eclipse. Follow the instructions from here and in step 4 use the location you noted down above(i.e. C:\SonyEricsson\JavaME_SDK_CLDC\)
Now create a new Midlet class following the instructions from here and replace the template code with this:
package com.randomconsultant.test;
import java.util.Date;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class MyMidlet extends MIDlet {
Alert timeAlert;
public MyMidlet() {
timeAlert = new Alert("Alert!");
timeAlert.setString(new Date().toString());
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(timeAlert);
}
}Now you can run in debug mode in the phones emulator
You should see the date pop up for a moment in the emulator.Now that we know we have a working app, we can try deploying it onto our phone. You have to create a package that will create a jad and jar file:
Now connect your phone via the usb cable or using bluetooth and copy the jad and jar file to somewhere on your phone.
Disconnect your phone from your pc, and open file manager on your phone ( Menu > Organizer > File Manager on my K850i) and select the jad file you copied over. Click on it and it will ask you where you would like to install the jad file (i.e. in applications or games).
Now your application can be selected from which ever menu you added it to (applications or games) and you will be able to run it!
For all my source code you can download it from here.
Leave a comment if you can't get this working or need a hand.