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
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 in java-forums.org,javaprogrammingforums.com,thenewboston. com/forum