Reputation: 41
Hi there I am trying to send a sms message using Java with a GSM Modem I am learning from this URL: http://www.codeproject.com/Tips/492716/How-to-send-SMS-using-Java-with-a-HSDPA-Dongle Here is my code:
import com.harshadura.gsm.smsdura.GsmModem;
public class TestSMS {
private static String port = "COM1"; //Modem Port.
private static int bitRate = 9600; //this is also optional. leave as it is.
private static String modemName = "ZTE"; //this is optional.
private static String modemPin = "0000"; //Pin code if any have assigned to the modem.
private static String SMSC = "+9477000003"; //Message Center Number ex. Mobitel
public static void main(String[] args) throws Exception {
GsmModem gsmModem = new GsmModem();
GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC);
gsmModem.Sender("+917350320106", "Test Message"); // (tp, msg)
}
}
I have added the various libraries to the built path of my project:
comm.jar
commons-net-3.0.1.jar
smsdura-1.0.jar
RXTXcomm.jar
However, I get this error when i run the project: Exception in thread main org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.NoSuchPortException
Please help
Upvotes: 0
Views: 1432
Reputation: 673
This error can occur due to several reasons.
Upvotes: 0
Reputation: 31
First fill arguments in this line "GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC);"
1.port can simply right click the MyComputer Icon > go to Mange > then Search for Modems > then it will pop up a interface with several tabs. Okay then you can simply notice theirs a Name called port. In front of that there is the port number. Now you know the port number. Insert that into the code. 2.Modem name is a optional thing 3.Bit rate? Leave it as it is. Or change to a proper one. The number will change depending modem to modem. 4.Some modems are using PIN numbers for Security. Does your one also using such a pin? If so please insert it to the code. if you have code in your modem 5.fill your network service center no...check your message setting..
Upvotes: 1