Thursday, May 14, 2009

QnA - Bat ayaw gumana ng 'Double.parseDouble(...)' sa J2ME application ko?

Naencounter ko lang tong tanong na to lately. Two things:

1. Meron kang class na ginawa na ang name ay 'Double'
2. Ang configuration mo ay CLDC 1.0 instead of CLDC 1.1

Now yung number 1 sa taas, madali lang gawan ng paraan. Either use a fully qualified name or rename mo na lang yung class mismo.

Yung number 2, madali lang din gawan ng paraan. If you're using Netbeans:

1. sa kaliwa ng screen, there's a 'Projects' tab. Right click mo yung project mismo na nag e-error yung 'double' then select 'Properties'.
2. Sa 'Device Configuration:' na field, select 'CLDC-1.1' instead of 'CLDC-1.0' and hit 'Ok'. That should do the trick.

Under Eclipse, accidentally setting it to CLDC 1.0 ay may pagka-rare kasi puro 1.1 na yung configuration but just in-case you want to know kung pano gawin to under Eclipse:

1. Sa 'Package Explorer' sa kaliwang side ng screen, Right click mo yung project mismo na nag-e-error yung 'double' then select 'Properties'.
2. Sa mga choices sa kaliwa, click on 'Java ME'
3. Click on 'Manage Devices' button sa kanan.
4. Click mo yung appropriate na device that you are developing for. Just make sure na 'CLDC1.1' yung pipiliin mo sa mga choices. then click 'Ok' sa mga window.

Brief background lang kung bakit sa CLDC1.0 eh nag-e-error yung mga double, float, etc. Kasi sa CLDC1.0, floating point operations are not fully supported. Kasi during that time, yung mga small device processors na target ng J2ME does not support floating point operations. Pero sa CLDC1.1, wala na po tong problem na to.

That's it pancit! :) Happy coding! :D

No comments:

Post a Comment