×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    11

    Problem using JSR-179

    Hello,

    I'm trying to use several codes to find latitude and longitude and concatenate them using a string but each time i get the following error message:

    D:\Dissertation\Software\MobileApplication1\src\FindingPosition.java:121: cannot find symbol
    symbol : method append(double)
    location: class java.lang.StringBuffer
    string = "\nLatitude : " + lat + "\nLongitude : " + lon;
    Fatal Error: Unable to find method append
    D:\Dissertation\Software\MobileApplication1\nbproject\build-impl.xml:389: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 0 seconds)

    source code is:
    Code:
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.location.Coordinates;
    import javax.microedition.location.Criteria;
    import javax.microedition.location.Location;
    import javax.microedition.location.LocationException;
    import javax.microedition.location.LocationProvider;
    import javax.microedition.midlet.MIDlet;
    
    public class FindingPosition extends MIDlet implements CommandListener {
    
        private Display display;
        private Form form;
        private Command exitCommand;
        private Command refreshCommand;
        private StringItem text;
        
        private Location location;
        private LocationProvider locationProvider;
        private Coordinates coordinates;
        private Criteria criteria;
    
        /**
         * Constructor. Constructs the object and initializes displayables.
         */
        public FindingPosition() {
            form = new Form("Finding location.");
    
            exitCommand = new Command("Exit", Command.EXIT, 2);
            refreshCommand = new Command("Refresh", Command.OK, 1);
    
            text = new StringItem("Your position:", "\nPress \"Refresh\"");
            form.append(text);
    
            form.addCommand(exitCommand);
            form.addCommand(refreshCommand);
            form.setCommandListener(this);
    
            display = Display.getDisplay(this);
            display.setCurrent(form);
    
            criteria = new Criteria();
            criteria.setHorizontalAccuracy(500);
            
            try {
                locationProvider = LocationProvider.getInstance(criteria);
            } catch (LocationException e) {
                //TODO: Handle location exception.
                return;
            }
        }
    
        /**
         * From MIDlet.
         * Called when the MIDlet is started.
         */
        public void startApp() {
            // No implementation required.
        }
    
        /**
         * From MIDlet.
         * Called to signal the MIDlet to enter the Paused state.
         */
        public void pauseApp() {
            // No implementation required.
        }
    
        /**
         * From MIDlet.
         * Called to signal the MIDlet to terminate.
         * @param unconditional whether the MIDlet has to be unconditionally
         * terminated
         */
        public void destroyApp(boolean unconditional) {
            // No implementation required
        }
    
        /**
         * From CommandListener.
         * Called by the system to indicate that a command has been invoked on a
         * particular displayable.
         * @param cmd the command that was invoked
         * @param displayable the displayable where the command was invoked
         */
        public void commandAction(Command c, Displayable d) {
            if (c == refreshCommand) {
                checkLocation();
            } else if (c == exitCommand) {
                notifyDestroyed();
            }
        }
    
        /**
         * Called to read current location.
         */
        private void checkLocation() {
            String string;
            
            try {
                location = locationProvider.getLocation(60);
            } catch (Exception e) {
                //TODO: Handle exception.
                return;
            }
            
            coordinates = location.getQualifiedCoordinates();
           
            if (coordinates != null)
            {
                // Use coordinate information 
                double lat =  coordinates.getLatitude();
                
                double lon =  coordinates.getLongitude();
                
                string = "\nLatitude : " + lat + "\nLongitude : " + lon;
            } 
            else
            {
                string = "Location API failed";
            }
            text.setText(string);
        }
    }
    Besiddes each time I cast the double to long (as mentioned below) compiler says:

    Code:
     long lat =  (long) coordinates.getLatitude();
                
                long lon =  (long) coordinates.getLongitude();
    Error msg:

    Error preverifying class FindingPosition
    java/lang/VerifyError:
    D:\Dissertation\Software\MobileApplication1\nbproject\build-impl.xml:461: Preverification failed with error code 1.

    cleaned and built but same results but if i create a new project and use the same class, it is built successfulluy but phone says invalid jar file

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Problem using JSR-179

    Quote Originally Posted by yasirmx View Post
    symbol : method append(double)
    location: class java.lang.StringBuffer
    string = "\nLatitude : " + lat + "\nLongitude : " + lon;
    Fatal Error: Unable to find method append
    This sounds like you're building with the CLDC-1.0 library in the class path, and not CLDC-1.1 (or, you have both, and 1.0 is first).

    Quote Originally Posted by yasirmx View Post
    Code:
     long lat =  (long) coordinates.getLatitude();
                
                long lon =  (long) coordinates.getLongitude();
    You really don't want to do this... you lose the fractional part of the value, which is a significant amount of data.

    Quote Originally Posted by yasirmx View Post
    Error preverifying class FindingPosition
    java/lang/VerifyError:
    D:\Dissertation\Software\MobileApplication1\nbproject\build-impl.xml:461: Preverification failed with error code 1.
    Hmmm... the preverifier is rarely helpful with its error messages... but this could also result from CLDC-1.0.

    Quote Originally Posted by yasirmx View Post
    i create a new project and use the same class, it is built successfulluy
    This makes sense... the problem is in the project settings, and the new project probably has CLDC-1.1 selected.

    Quote Originally Posted by yasirmx View Post
    but phone says invalid jar file
    Lots of things can cause this, start by reading this. What device are you installing on? A common pitfall is to have MIDP-2.1 selected in the project settings, and a MIDP-2.0 device (so, the phone believes it cannot run the application).

    Graham.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    11

    Re: Problem using JSR-179

    Thanks for the reply but I need further advices. I'm trying to install on N95. It's cldc 1.0 and midp 2.0 rite? i've set the config to lower versions (1.0 and 2.0) to provide backward compatibility. If i try new config, the app won't work.

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Problem using JSR-179

    No, check the N95 specs. You cannot use JSR 179 with CLDC-1.0, you must use CLDC-1.1.

Similar Threads

  1. devices supporting jsr 179
    By khristopher in forum Mobile Java General
    Replies: 15
    Last Post: 2011-09-21, 10:06
  2. Problems in Installing jar and jad file on to Nokia 6300
    By kris_sagar in forum Mobile Java Networking & Messaging & Security
    Replies: 27
    Last Post: 2009-05-22, 08:01
  3. JSR 179 Implementation
    By gruntzd in forum Mobile Java General
    Replies: 1
    Last Post: 2007-02-26, 07:31
  4. 6230 and JSR 82 problem
    By Robert111 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2004-11-11, 10:02
  5. 6230 and JSR 82 problem
    By Robert111 in forum Mobile Java General
    Replies: 2
    Last Post: 2004-11-02, 13:39

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×