Wednesday, April 16, 2008

A mobile Application

Though there are a lot of sample projects given with Netbeans IDE, I thought I could really demonstrate its full potential in MIDP through a simple step by step robust application design for a Celsius to Kelvin scale converter app for java enabled phone.
  1. Select File->New Project->Mobility->MIDP Application
  2. Set the project name as MobileConverter and remember to keep Set as main project and Create HelloMIDlet checked
  3. Select the emulator type, here we’ll tryout the Sun JAVA™ wireless. We’ll be right now programming for a default Color phone with the older CLDC 1.0 config and MIDP-1.0 profile(That’s what my phone supports). Click finish.
  4. Goto the Screen view and let us now. Click on the text and change its property to Hello, Welcome to Mobile Converter
  5. Goto Palette and drag and drop a text field item and label it as input.
  6. Drag an Ok command from the list of Commands and label it as Convert.
  7. Now goto the flow tab and drop in a new form. Name it as output form.
  8. Drag a back command and drop it on our new form. Draw connection lines as shown.
  9. Goto the screen tab, choose the new form and drop in a textfield to show our output.
  10. Now goto the source code. Write the following method in your MIDlet class.

public void setans()

{

float x=Float.parseFloat(textField.getString());

x+=273.15;

textField1.setString(String.valueOf(x));

textField.setString("0");

}

  1. Goto screen, in the new form right click and goto source. In the place where you find // write post-init user code here call the setans method by setans();
  2. You finally have your own mobile app. Click on build and then deploy. Your jar file will be generated in the dist folder. Transfer it to your java enabled phone and enjoy ;)

11 comments:

Unknown said...

hey i tried to build the application using ur tutorial..its really useful..so great job with the tutorial. i just had one problem..when i transferred the executable jar file on my cell phone, it said invalid application..i tried to use different handsets too but it doesnt work..i wondering is it the emulator that is causing the prob ? because we use the default colorphone..if u any idea about it plz let me know.

Unknown said...

Dear Kapil,
Please use a Java enabled cellphone. Not all colour phones support java apps...

Unknown said...

hello i hava nokia n73 but i i complile JAR file!!1 & open it in n73 it says "NOT A VALID JAR FILE"
:( PLS HELP

Harsh Chhatwani said...

can you please tell me how to select emulator type?i have already made a project and it is running successfully,now i want to install it in my mobile.please guide

Unknown said...

Hi Kapil,

Really i is appriciable to start such blog.

Right now I want to develop a mobile slam book like below:
Name:
DOB:
eMAIL:
MOBILE:

after filling this information, msg will sent to predefined number.

Can you help me for the same.

best reg.

Amar Verma.

Unknown said...

Hey its really amiging. Keep Sharing.



blackberry phone deals with free gifts

Unknown said...

Hey bro,nice post
I tried it and its working fine
its described nicely

vaibhav said...

can you please help me in including database connectivity in such an application. for example i want a login page and the entered info goes into the database... please its urgent

Unknown said...

read http://www.java-tips.org/java-me-tips/midp/connecting-to-databases-like-mysql-sql-server-or-oracle-on-j2me-de.html and this http://forums.netbeans.org/topic13510.html

Unknown said...

need help
i got this bug when i resubmit input the output is the same

Unknown said...

I'm astounded. You're sincerely decently educated and extremely canny. I am set to bookmark this site.iPhone app builder // iphone applications // Android application development