Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.microedition.location can not be resolved

 
Husnain Kazmi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am writing a program on java eclipse to get the coordinates through a GPS module TC65. I imported the "javax.microedition.location" file but my program is giving the following error:

javax.microedition.location can not be resolved

Can anyone help me in theis regard?

Thanks
 
Tim Holloway
Saloon Keeper
Posts: 18365
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Husnain!

Java Location Services is not part of the basic JME package. It's a JSR extension. Not all hardware supports it, so you need to check the specs from your hardware vendor to see if JSR-179 support comes with the device you're interested in.
 
Husnain Kazmi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Tim,

Thank you for your reply. Forgive me if my question seems stupid.. Actually I am working for the first time on Eclipse and just have the basic knowledge of JAVA.

i just wanted to ask if JSR-179 is not supported by my module, the TC-65, then what should I do??? Is there any alternative so that I can extract the location using my TC-65?

Thanks
 
Tim Holloway
Saloon Keeper
Posts: 18365
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is the device you're referring to:

http://www.mobiledata.com.au/Siemens-TC65.asp

I don't think it has GPS capabilities, so location services would only be possible using the cruder method of trilaterialization, and then only if the carrier provided that service. Since the main intent of the device is to provide an Internet connection or telephone services to fixed attached systems, it wouldn't be expecting its location to change very often.

So you apparently have no software because there's no hardware support for location services on this unit. In theory you could plug in an external GPS device, but you'd have to provide your own drivers. Many GPS devices present themselves as serial ASCII communications devices, so you could use the standard file/serial I/O (java.io) classes to track position without using the javax.microedition services.
 
Husnain Kazmi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Tim, I am actually working on HCP65-G. Its a Quad band GSM Modem with GPS Receiver. I am attaching the whole code. If you have a look at it, maybe you can find some error.


package src;

import java.io.*;
import javax.microedition.midlet.*;
//import javax.microedition.lcdui.*;
import java.util.Enumeration;
import java.util.Hashtable;
import j2melocation.doc.api.javax.microedition.location.*;

public class TstGPSMain extends MIDlet
{
String error = "";
//private static Display display = null;


protected void startApp() throws MIDletStateChangeException
{
//display = Display.getDisplay(this);
System.out.println("loading");

LocationProvider lp=null;
j2melocation.doc.api.javax.microedition.location.Location location=null;

try
{
lp= LocationProvider.getInstance(null);
}
catch(LocationException e)
{
addError(e);
}

try
{
//timeout
location = lp.getLocation(20);
}
catch(LocationException e)
{
addError(e);
}
catch(InterruptedException e)
{
addError(e);
}

String res="[RESULTS]\n";
try{

Coordinates coordinates = location.getQualifiedCoordinates();

res+="Altitude:"+coordinates.getAltitude()+"\n";
res+="Latitude:"+coordinates.getLatitude()+"\n";
res+="Longitude:"+coordinates.getLongitude()+"\n";

}catch(Exception e){
addError(e);
}


Form f = new Form("Results");

f.append(res);
f.append(error);

//display.setCurrent(f);


}

void addError(Exception e){
e.printStackTrace();
error+=e.getMessage()+"\n";

}

protected void pauseApp()
{
}

protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException
{
}


//public static Display getDisplay()
{
// return display;
}



}

 
Tim Holloway
Saloon Keeper
Posts: 18365
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Helpful hint: if you use the "Code" button on the message editor to wrap code samples, they'll be more readable.

Just because a Java device supports GPS doesn't mean it supports JSR-179. They may have their own proprietary API for location services. Quite a few manufacturers do. I'd check with the manufacturer and see how they recommend using their GPS from Java code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic