Results 1 to 2 of 2
  1. #1
    Jhovarie is offline Banned
    Join Date
    Feb 2011
    Posts
    65
    Rep Power
    0

    Default This is Cool and interesting but i failed

    Hello guys does any one try this?

    i follow the tutorials here A Free Java Application for sending SMS using Java and GSM Modem connected to your PC COM port

    but i get an error don't know what is the problem.

    im trying this code
    Java Code:
    public class SMSClient implements Runnable{
    
      public final static int SYNCHRONOUS=0;
      public final static int ASYNCHRONOUS=1;
      private Thread myThread=null;
    
      private int mode=-1;
      private String recipient=null;
      private String message=null;
    
      public int status=-1;
      public long messageNo=-1;
    
    
      public SMSClient(int mode) {
          this.mode=mode;
        }
    
      public int sendMessage (String recipient, String message){
        this.recipient=recipient;
        this.message=message;
        //System.out.println("recipient: " + recipient + " message: " + message);
        myThread = new Thread(this);
        myThread.start();
    //    run();
        return status;
        }
        public void run(){
    
        Sender aSender = new Sender(recipient,message);
    
        try{
          //send message
              aSender.send ();
    
             // System.out.println("sending ... ");
    
          //in SYNCHRONOUS mode wait for return : 0 for OK, -2 for timeout, -1 for other errors
          if (mode==SYNCHRONOUS) {
              while (aSender.status == -1){
                myThread.sleep (1000);
              }
          }
          if (aSender.status == 0) messageNo=aSender.messageNo ;
    
        }catch (Exception e){
    
            e.printStackTrace();
    
        }
    
        this.status=aSender.status ;
        aSender=null;
        }
        public static void main(String[]args){
            new SMSClient(0).sendMessage("recipient number here", "Message Here");
        }
    }
    this is the error message

    javax.comm.NoSuchPortException
    at javax.comm.CommPortIdentifier.getPortIdentifier(Co mmPortIdentifier.java:105)
    at latest.SerialConnection.openConnection(SerialConne ction.java:76)
    at latest.Sender.send(Sender.java:41)
    at latest.SMSClient.run(SMSClient.java:36)
    at java.lang.Thread.run(Thread.java:662)
    java.lang.NullPointerException
    at latest.SerialConnection.openConnection(SerialConne ction.java:93)
    at latest.Sender.send(Sender.java:41)
    at latest.SMSClient.run(SMSClient.java:36)
    at java.lang.Thread.run(Thread.java:662)

    i add this code to invoke SMSLient
    public static void main(String[]args){
    new SMSClient(0).sendMessage("recipient number here", "Message Here");
    }
    don't know if this is correct or not? any one try this? please help . . . no idea.

    cross post java-forums.org,javaprogrammingforums.com,thenewboston. com/forum

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Interesting JButton Query
    By ravjot28 in forum AWT / Swing
    Replies: 3
    Last Post: 01-14-2010, 04:54 PM
  2. Replies: 1
    Last Post: 08-11-2009, 02:53 PM
  3. Interesting CS problem. Need help.
    By xtrmi in forum New To Java
    Replies: 1
    Last Post: 05-02-2009, 03:51 AM
  4. Interesting Experiment
    By uncommon in forum Advanced Java
    Replies: 13
    Last Post: 12-20-2008, 11:30 PM
  5. Cool Grid to manipulate with database records
    By leoleo4614 in forum AWT / Swing
    Replies: 2
    Last Post: 12-13-2008, 09:45 AM

Posting Permissions

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