johnnydarten 0 Newbie Poster

Hello Everyone! I have a question about Java ME SDK 3.0 It is that I was running a project which connects my mobile with a bluetooth module(mobile is server) then mobile sends data to another mobile in an SMS.I run the code then building is successful then I donot know why doesnot the emulator run?I used a UUID which I am not sure about as I donot know which UUID to use while trying the project on Java ME SDK 3.0

Here is my Code:

package doctor;
import java.io.*;
import javax.bluetooth.*;
import javax.microedition.io.*;
import javax.wireless.messaging.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Program extends MIDlet implements CommandListener {

    private Display display;
    private TextBox textBox1,textBox2,textBox3,textBox4;
    private Command entryCommand;
    private Command exitCommand;
        StreamConnection con = null;
        StreamConnectionNotifier service = null;
        private LocalDevice localDevice;
        InputStream ip = null;
        OutputStream op = null;
        StringBuffer serviceURL = new StringBuffer("btspp://");
        private UUID PICTURES_SERVER_UUID = new UUID ("F0E0D0C0B0A000908070605040302010", false);
///ANY UUID is used here()
    public void startApp() {
        display = Display.getDisplay(this);
        entryCommand = new Command("Start", Command.SCREEN, 1);
        exitCommand = new Command("Quit", Command.SCREEN, 1);
        textBox1 = new TextBox("How application works..", "This application helps to send an alert to the doctor to let him informed with his patient 's heart condition. It also allows the patient to monitor his heart illness and danger moments and how often does it happen.", 256, 0);
        textBox1.addCommand(entryCommand);
        textBox1.addCommand(exitCommand);
        textBox1.setCommandListener(this);
        display.setCurrent(textBox1);
        try {
            localDevice = LocalDevice.getLocalDevice();
            localDevice.setDiscoverable (DiscoveryAgent.GIAC);
            serviceURL.append("localhost").append(":");
            serviceURL.append (PICTURES_SERVER_UUID.toString ());
            serviceURL.append(";name=CallDoctor");
            serviceURL.append (";authorize=false");//"btspp://localhost:1101";
        } catch (BluetoothStateException ex) {
            ex.printStackTrace();
        }
        }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command choice, Displayable displayable) 
    {
        if (choice == exitCommand) 
        {destroyApp(false);
         notifyDestroyed();
        } 
        else
        {
            try {
                service = (StreamConnectionNotifier) Connector.open(serviceURL.toString());
                con = service.acceptAndOpen();
             } catch (IOException ex) {
                ex.printStackTrace();
            }
  
    textBox2=new TextBox("Program is running...","Waiting for requests",81,0);
    //textBox2.addCommand(exitCommand);
    //textBox2.setCommandListener(this);
    display.setCurrent(textBox2);
    try{
    ip=con.openInputStream();
    op=con.openOutputStream();}catch(IOException ex){ex.printStackTrace();}
    dataobj A = null,B = null,C = null;
      ReadThread rdthr=new ReadThread(ip);
      rdthr.run(A);
      B.STOREDATA(A.RETRIEVEDATA());
                try {
                    writedata(B.RETRIEVEDATA());
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
      ReadThread rdthr1=new ReadThread(ip);
      rdthr1.run(C);
      if(B.RETRIEVEDATA()!=C.RETRIEVEDATA())
      {textBox3=new TextBox("ERROR","Error in received sequence.Application closed.",81,0);
       display.setCurrent(textBox3);
       int i=127;    //waiting time 256 counts
        i=i-1;
       destroyApp(false);
       notifyDestroyed();}
      SMSender URGENT=new SMSender("0");
      URGENT.send("Patient case is severe", "0108646516");
      textBox4=new TextBox("Message sent","Reported the message Recieve requests again?",81,0);
      entryCommand = new Command("Start", Command.SCREEN, 1);
      textBox4.addCommand(exitCommand);
      textBox4.setCommandListener(this);
      display.setCurrent(textBox4);
        }
       

    }
public void writedata(char data) throws IOException
  {try{op.write(data);}
      catch(IOException e) 
         {e.printStackTrace();}
  }
}
class ReadThread extends Thread
{InputStream ip=null;
 public ReadThread (InputStream inp){ip=inp;}
 public void run(dataobj Z)
 {char datae = 0;
  try{
      datae=(char)ip.read();
      Z.STOREDATA(datae);
     }
  catch(IOException e){}
 }
}
class dataobj
{char data;
 public void STOREDATA(char X)
 {data=X;}
 public char RETRIEVEDATA()
 {return data;}
}

 class SMSender implements Runnable {
  private String smsReceiverPort;
  private String message;
  private String phoneNumber;

  public SMSender(String smsReceiverPort) {//till now not used
    this.smsReceiverPort = smsReceiverPort;
  }

  public void run() {
    StringBuffer addr = new StringBuffer(20);
    addr.append("sms://+");
    if (phoneNumber.length() == 10)
      addr.append("20");// Egypt

    addr.append(phoneNumber);
    // String address = "sms://+020108646516";
    String address = addr.toString();

    MessageConnection smsconn = null;
    try {
      // Open the message connection.
      smsconn = (MessageConnection) Connector.open(address);
      // Create the message.
      TextMessage txtmessage = (TextMessage) smsconn
          .newMessage(MessageConnection.TEXT_MESSAGE);
      txtmessage.setAddress(address);// !!
      txtmessage.setPayloadText(message);
      smsconn.send(txtmessage);
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (smsconn != null) {
      try {
        smsconn.close();
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }
  }
  public void send(String message, String phoneNumber) {
    this.message = message;
    this.phoneNumber = phoneNumber;
    Thread t = new Thread(this);
    t.run();}

 }

Thanks in advance