System.getProperty( "com.nokia.mid.imei" ) return null ?!?!

hello guys,

i intend to get the IMEI No. i wrote the following code:

import javax.microedition.lcdui.*;

import javax.microedition.midlet.*;

publicclass IMEIDemoextends MIDlet

{

Display display;

private Form mainForm;

String imeiNokia ="";

publicvoid startApp()

{

display = Display.getDisplay(this );

mainForm =new Form("IMEI Demo" );

imeiNokia = System.getProperty("com.nokia.mid.imei" );

if( imeiNokia.compareTo("" ) == 0 )

{

System.out.println("NULL..." );

}

else

{

mainForm.append( imeiNokia );

display.setCurrent( mainForm );

}

}

publicvoid pauseApp()

{

}

publicvoid destroyApp(boolean b )

{

destroyApp(false );

notifyDestroyed();

}

}// IMEIDemo

i am using WTK2.2, MIDP2, CLDC1.1

when i run this code in emulator (WToolKit), i got the following Exception:

startApp threw an Exception

java.lang.NullPointerException

java.lang.NullPointerException

at IMEIDemo.startApp(+36)

at javax.microedition.midlet.MIDletProxy.startApp(+7)

at com.sun.midp.midlet.Scheduler.schedule(+270)

at com.sun.midp.main.Main.runLocalClass(+28)

at com.sun.midp.main.Main.main(+116)

would u pls suggest me how can i overcome this problem or any effective openion?

thanx in advance.

take care all.

bye.

[2545 byte] By [MicroEditiona] at [2007-10-3 3:27:47]
# 1
I'll throw in my thoughts...Suns WTK is going to return null for that getProperty call since its a property that is exclusive to nokia handsets. My suggestion is to try the same code running in Nokia's WTK, which you can get at developer.nokia.com
mcarrona at 2007-7-14 21:21:16 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

but i am totally confused that which link should i use of ur given link "developer.nokia.com".

another thing that i want to use a generic method by which i can pick the IMEI #. not for only nokia set. that method will work as well as the other set. is there any method? if so, pls let me know from u.

the last thing, which emulator should i use for nokia set, if u know, then pls give me the link so that i can download and test the program.

thanx in advance.

bye

MicroEditiona at 2007-7-14 21:21:16 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

http://developer.nokia.com/main/resources/tools_and_sdks/listings/java_tools.html

There are sdk's for both the S40 and S60 platforms, you should be able to test with these.

Generically your going to run into some issues since, other manufacturers will not have a method to obtain the IMEI or if they do it will be different string. For the specifics, going to have to go to the manufacturers dev site and read their documentation.

mcarrona at 2007-7-14 21:21:16 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

hi

i tried this program using J2ME to retireve IMEI number

*

* IMEINO.java

*

* Created on February 19, 2007, 3:50 PM

*/

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

/**

*

* @author Administrator

* @version

*/

public class IMEINO extends MIDlet implements CommandListener{

public TextField t1,t2,t3;

public Form form;

public String s1,s2,s3,n=null;

public Display disp;

public Command ok,exit;

public IMEINO()

{

form = new Form("IMEI");

t1 = new TextField("imei1","",50,TextField.ANY);

t2 = new TextField("imei2","",50,TextField.ANY);

t3 = new TextField("imei3","",50,TextField.ANY);

ok = new Command("ok",Command.OK,1);

exit = new Command("exit",Command.EXIT,2);

}

public void startApp() {

form.addCommand(ok);

form.setCommandListener(this);

form.addCommand(exit);

form.setCommandListener(this);

form.append(t1);

form.append(t2);

form.append(t3);

Display disp = Display.getDisplay(this);

try

{

s1 = System.getProperty("com.nokia.mid.imei");

s2 = System.getProperty("phone.imei");

s3 = System.getProperty("com.nokia.IMEI");

if(s1.compareTo("") == 0 || s2.compareTo("")==0 || s3.compareTo("")==0 )

{

t1.setString(null);

}

else

t1.setString(s1);

t2.setString(s2);

t3.setString(s3);

}

catch(Exception e)

{

t1.setString("error"+ e.getMessage());

t2.setString(s2);

t3.setString(s3);

}

disp.setCurrent(form);

}

public void commandAction(Command c,Displayable d)

{

if(c==ok)

{

destroyApp(true);

notifyDestroyed();

}

if(c == exit)

{

destroyApp(true);

notifyDestroyed();

}

}

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {

}

}

i tried this program , when i run in the netbeans environment , it shows null (system.out.println(imei)),when i installed the jar file into nokia 3230 mobile,the textfield is null , it shows nothing,can anyone give me any suggestion , whether i have to change my phone settings

Message was edited by:

scorpianalways

scorpianalwaysa at 2007-7-14 21:21:16 > top of Java-index,Java Mobility Forums,Java ME Technologies...