Cannot create an instance of Location.Criteria class - lapi.jar MIDP 2.0 J2ME



Hello

I am trying to find out the good provider for a kind of GPS program
written with j2me midp 2.0 using the location API (lapi.jar) and
Eclipse development environment with the plugin 'eclipseME'.

I have a very strange phenomena.
I try to create an instance of the Criteria class which is part of the
Location API (lapi.jar).

I can compile it without any problems, the program crashes at runtime.
My programm crashes with the following error line:
java.lang.NoClassDefFoundError: javax/microedition/location/Criteria
The lapi.jar is included in the project and the Criteria class exists.

Here is my code:

private LocationProvider FindProvider()
{
LocationProvider oProvider = null;
boolean bProviderFound = false;
int nDistance = 50;

while(!bProviderFound)
{
// set the distance
Criteria oCriteria = new Criteria();
oCriteria.setHorizontalAccuracy(nDistance);
oCriteria.setCostAllowed(false);

try { LocationProvider.getInstance(oCriteria); }
catch(Exception ex)
{
txtGPSData.setString("No provider available - please try
again");
return null;
}

if(oProvider != null)
bProviderFound = true;
}
return oProvider;
}

It crashes exactly where I instantiate the new Criteria object and for
some strange reasons the debugger of eclipse shows me the
Display.class?? But I use my textbox somewhere completely else in my
code.
Unfortunatly the eclipse debugger does not tell me any useful
error-message.

I am not a very good experienced java programmer (normaly doing C#)
and MIDP is quite new for me.
Any help would be very much appreciated. Thanks very much.
.



Relevant Pages

  • Re: Eclipse bug?
    ... What's a good choice that meets the following criteria: ... Easy to set up and use with Eclipse ... Win32 is a supported platform ...
    (comp.lang.java.programmer)
  • Re: XPATH - How to get rid of warnings or whats wrong!
    ... thank you for your reply - i use eclipse as my IDE and maybe because of ... that the behaviour is strange but i still get the warnings only if i ... use the console i dont get them! ...
    (comp.lang.perl.misc)