This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes javax.microedition.location can not be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "javax.microedition.location can not be resolved" Watch "javax.microedition.location can not be resolved" New topic
Author

javax.microedition.location can not be resolved

Husnain Kazmi
Greenhorn

Joined: Oct 30, 2010
Posts: 3
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

Joined: Jun 25, 2001
Posts: 16158
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Husnain Kazmi
Greenhorn

Joined: Oct 30, 2010
Posts: 3
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

Joined: Jun 25, 2001
Posts: 16158
    
  21

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

Joined: Oct 30, 2010
Posts: 3
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

Joined: Jun 25, 2001
Posts: 16158
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.microedition.location can not be resolved