×

Discussion Board

Results 1 to 3 of 3

Threaded View

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    1

    [moved] SIP Receiver on Nokia 3110

    HI I am trying to run a SIP listernet on a nokia 3110 The application snipet works in th eemulator but when i download to phone it generates a error "Uncaught exception java/lang/NoClassDefFoundError: SIP/MySIP2: javax/microedition/sip/SipServerConnectionListener ."

    code is:-

    Code:
    package SIP;
    
    import java.util.*;
    import java.io.*;
    import javax.microedition.io.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    import javax.microedition.sip.*;
    
    public class MySIP2 extends MIDlet
        implements CommandListener, SipServerConnectionListener  {
    
        private Display display;
        private long startTime;
        private Form form;
        private TextField receivePort;
        private Command receiveCmd;
        private Command exitCmd;
        SipConnectionNotifier scn = null;
        SipServerConnection ssc = null;
    
        public MySIP2() {
    
            try
            {
            System.out.println("MIDlet: SipMIDlet starting...");
            display=Display.getDisplay(this);
            form = new Form("Receive Message");
            receivePort = new TextField
                ("Give receive port:", "sip:5080", 30,
                TextField.LAYOUT_LEFT);
            form.append(receivePort);
            receiveCmd = new Command("Start", Command.ITEM, 1);
            exitCmd = new Command("Exit", Command.EXIT, 1);
            form.addCommand(receiveCmd);
            form.addCommand(exitCmd);
            form.setCommandListener(this);
            Thread t = new Thread() {
                    public void run() {
                    receiveMessage();
                    }
                };
                t.start();
            }  catch(Exception ex) {
                ex.printStackTrace();
            }
    
        }
    
        public void commandAction(Command c, Displayable d) {
            if(c == receiveCmd) {
                Thread t = new Thread() {
                    public void run() {
                    receiveMessage();
                    }
                };
                t.start();
            }
            if(c == exitCmd) {
                if(scn != null) {
                    try {
                        scn.close();
                    }
                    catch(IOException iox) {
                    }
                }
                destroyApp(true);
            }
        }
    
        public void startApp() {
            display.setCurrent(form);
            System.out.println("MIDlet: SipMIDlet startApp()");
        }
    
        public void receiveMessage() {
            try {
                if(scn != null)
                scn.close();
                scn = (SipConnectionNotifier)
                    Connector.open(receivePort.getString());
                scn.setListener(this);
                form.append("Listening... in port: "+scn.getLocalPort());
            } catch(Exception ex) {
                ex.printStackTrace();
            }
        }
    
        public void notifyRequest(SipConnectionNotifier scn) {
            try {
                ssc = scn.acceptAndOpen();
                if(ssc.getMethod().equals("MESSAGE")) {
                String contentType = ssc.getHeader("Content-Type");
                String contentLength = ssc.getHeader("Content-Length");
                int length = Integer.parseInt(contentLength);
                if((contentType != null) &&
                    contentType.equals("text/plain")) {
                    InputStream is = ssc.openContentInputStream();
                    int i=0;
                    byte testBuffer[] = new byte[length];
                    i = is.read(testBuffer);
    
                    String tmp = new String(testBuffer, 0, i);
    
                    StringItem st = new StringItem
                        ("Subject:", ssc.getHeader("Subject"));
                    form.append(st);
                    st = new StringItem("Message:", tmp);
                    form.append(st);
                }
                ssc.initResponse(200);
                ssc.send();
            }
    
            } catch(IOException ex) {
                form.append("Exception: "+ex.getMessage());
            }
    
        }
    
        public void pauseApp() {
            System.out.println("MIDlet: pauseApp()");
        }
    
        public void destroyApp(boolean b) {
            System.out.println("MIDlet: destroyApp()");
            notifyDestroyed();
        }
    
    
         public
    class LinkageError extends Error {
         public LinkageError() {
              super();
          }
    
         public LinkageError(String s) {
              super(s);
          }
       }
    
       public
      class NoClassDefFoundError extends LinkageError {
         /**
           * Constructs a <code>NoClassDefFoundError</code> with no detail message.
           */
           public NoClassDefFoundError() {
             super();
          }
    
           /**
            * Constructs a <code>NoClassDefFoundError</code> with the specified
            * detail message.
          *
             * @param   s   the detail message.
          */
          public NoClassDefFoundError(String s) {
               super(s);
         }
       }
    
    }
    Last edited by ltomuta; 2009-10-22 at 22:25. Reason: Code formatting

Similar Threads

  1. Nokia N-Series Complete Model Line-Up
    By Dopod in forum General Development Questions
    Replies: 6
    Last Post: 2008-07-22, 20:16
  2. which phones for laptop
    By dvdljns in forum PC Suite API and PC Connectivity SDK
    Replies: 2
    Last Post: 2006-02-14, 12:58

Posting Permissions

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