Thursday, 10 July 2014

Create Your First Mobile Application in Eclipse [J2ME]


In this tutorial I'm going to show you how to create a simple mobile application in Eclipse IDE.

First you have to download the Eclipse IDE. You do not need to pay for it, its free :)
http://www.eclipse.org/downloads/

To create mobile applications you have to download the j2me plugin.
http://eclipseme.org/

To install the plugin follow the below tutorial.
http://eclipseme.org/docs/installEclipseME.html

Now you can create any j2me mobile application in eclipse.

In here we are going to develop a simple mobile application.

STEP 1

To Create New J2ME Project
File -> New -> select j2me --> j2me Midlet suite -> click Next





Give the project name as HelloworldMobileApp and click Next

In Midlet Suite Properties use the default settings.



Click Next and Finish.

Now you can see it create your project in Project area.
STEP 2

Now select the project right click it and New --> Other



Select J2ME Midlet and click Next. Give a name for the midlet. In here i gave it as HelloworldMidlet and click finish.

It create the HelloworldMidlet class and inherit the some methods.

Now add these following code.

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


public class HelloworldMidlet extends MIDlet {
private Form form;
private Display display;

public HelloworldMidlet() {
form = new Form("My First J2ME App");
String msg = "Hello World";
form.append(msg);
display = Display.getDisplay(this);
display.setCurrent(form);
}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
notifyDestroyed();
}

protected void pauseApp() {
// TODO Auto-generated method stub

}

protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub

}

}



STEP 3

We did finish coding now. But in order to run your app you have to do some configuration.

Right click the project --> Run as --> Run Configuration

Click Browse and select the project.




and Click Run

Now you can see it start the mobile device and show hello world.




No comments:

Post a Comment