user3631251
user3631251

Reputation: 41

Java error sending sms message with gsm modem

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

Answers (2)

Jananath Banuka
Jananath Banuka

Reputation: 673

This error can occur due to several reasons.

  1. Your dongle software might be opened. So close it, double check if its running as a background service by using Task Manager. Kill it if it still runs.
  2. Your SMSLib configurations to JVM is not affected properly. So check again the required files are there or not. You need to place them both JDK and JRE see 1
  3. This program does not work well with 64Bit JVM, but it does not say you cannot use it in a 64 bit machine. You have installed 32Bit JDK on the machine, remove the 64Bit JDK to prevent mix ups.
  4. The port you going to access might not really be available in the system. You can simple check the Dongle port if its there by: right clicking Computer icon then go manage > then select device manager > then expand Ports(COM LPT) column > You will see the Application interface port of your device. Thats the port you have to use thre.

Upvotes: 0

user1905654
user1905654

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

Related Questions