Friday 4 September 2015

How to install j2me in windows?

As i wasted hours installing the sofware for developing java mobile applications, i thought i would summarise the method i followed so that in future nobody wastes as much the time i wasted.
Basically you could install j2me via one of these ways


  • Jave ME SDK
  • Netbeans or Eclipse integration with plugin
  • External softwares 
I tried the first two and ended up regretting, so i tried the third method and it worked :)
I used Sun-Wireless Toolkit 2.5.2 ML
 

NOTE: you must have 32 bit JRE,JDK for this to work. If you dont have 32 bit version download it from java website. If you are not sure whether you have 32 bit version go to
 C:\Program Files (x86)\Java\ 
if you have both jdk and jre , fine you are ready to continue further else install the missing parts


Start the installation:





After installing open the s/w ( you would have a shortcut in desktop)
Click new project to create a new project





Give project name, Midlet class name with be the name of the program




Note down the project location which is shown in the screen, you have to save your source code in the "src" folder  which is inside ur projecct folder ( here project folder name is Helloworldproject)



here is a sample code to test:

Saved the file as Helloworldmidlet.java ( in src folder inside the Project folder )

<code>
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class Helloworldmidlet extends MIDlet {
    
    // The MIDlet's Display object
    protected Display display;
    
    // Flag indicating first call of startApp
    protected boolean started;
    
    protected void startApp() {
        if (!started) {
            display = Display.getDisplay(this);
            
            Form form = new Form("Item Layout");
            
            form.append("Hello");
            form.append("World");
            
            form.append("\nLet's start\na new line\n");
            form.append("This is quite a long string that may not fit on one line");
            
            form.append(new TextField("Name", "J. Doe", 32, TextField.ANY));
            form.append("Address");
            form.append(new TextField(null, null, 32, TextField.ANY));            
            
            display.setCurrent(form);
            
            started = true;
        }
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean unconditional) {
    }
}
</code>


No comments:

Post a Comment

Binary Search Algorithm Variations and Problems

Binary Search is a simple algorithm but is tricky when it comes to implementing it. The lower and upper bounds have to be set carefully to...