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

R

Roland

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.
 
D

Daniel Dyer

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.

Looks like a classpath problem, is the lapi.jar included in the classpath
when you run your app? Are you running on an emulator or an actual
device? You need to configure your emulator or the manifest in your app's
jar file to include lapi.jar in the classapth.

OK, that's my token attempt to answer your question ;) the real reason I
replied is because I'm interested in which device(s) are you planning to
run on? We've been looking at JSR-179 (the J2ME location API) and it
seems to be almost universally unsupported by current generation mobile
phones. It seems to require both CDLC 1.1 for floating point support and
vendor support for the location API on the device (I may be wrong, my
colleagues have looked at this in more detail than I have personally). I
presume you are using some kind of reference implementation in an
emulator? We are targeting Symbian devices and are having to use C++ to
retrieve location information because of the lack of JSR-179 support. I'd
be very interested if you've got it working just with Java.

Dan.


P.S. Anybody else think there should be a comp.lang.java.mobile group?
 
R

Roland

Daniel Dyer said:
Looks like a classpath problem, is the lapi.jar included in the classpath
when you run your app? Are you running on an emulator or an actual
device? You need to configure your emulator or the manifest in your app's
jar file to include lapi.jar in the classapth.

OK, that's my token attempt to answer your question ;) the real reason I
replied is because I'm interested in which device(s) are you planning to
run on? We've been looking at JSR-179 (the J2ME location API) and it
seems to be almost universally unsupported by current generation mobile
phones. It seems to require both CDLC 1.1 for floating point support and
vendor support for the location API on the device (I may be wrong, my
colleagues have looked at this in more detail than I have personally). I
presume you are using some kind of reference implementation in an
emulator? We are targeting Symbian devices and are having to use C++ to
retrieve location information because of the lack of JSR-179 support. I'd
be very interested if you've got it working just with Java.

Dan.


P.S. Anybody else think there should be a comp.lang.java.mobile group?

Hi Dan

Thanks very much for your answer.
I think you are right, such special functions are not supportet by the
WTK.
I was reading a little bit more in this direction and I realized that
my phone K700 Sony-Ericsson is not supporting at all the Location API.
I wanted to implement this function instead of buying a GPS reciever
(I do not need the position extremly exact ;)
So I decided to stop my little private project and buying a GPS :))

I would be very much interested how you are doing this on Symbian.
Are you using MobiInfo API? Or is there another API which is providing
cell informations?

I am absolutly your opinion about the mobile newsgroup - this area
became so waste and becomes more more important that it would be very
useful to have an own newsgroup.

Best regards
Roland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top