1

I want my Java application to send and receive SMS without using any additional hardware devices and it must be free.

I made my search but all i found is titles, i found somethings like SMSLib but at the other hand i didn't find tutorials or books to learn that.

I also found that SMSLib code but didn't understand:

Send Message/SMS Code

package SMSEngine;
import org.smslib.*;
class SendMessage
{
public static void sendMessage(String number, String message)
{ 
CService srv = new CService("COM4",9600,"huawei","E220");
try
{
srv.setSimPin("0000");
srv.setSimPin2("0000");
srv.setSmscNumber("");
srv.connect();
COutgoingMessage msg = new COutgoingMessage(number, message); 
msg.setMessageEncoding(CMessage.MessageEncoding.Enc7Bit);
msg.setStatusReport(true);
msg.setValidityPeriod(8);
srv.sendMessage(msg);
srv.disconnect();
}
catch (Exception e)
{
e.printStackTrace();
}
System.exit(0);
}
}

Read Message/SMS Codes

package SMSEngine;
import org.smslib.*;
import java.util.*;
class ReadMessages
{
static CService srv;
public static LinkedList receiveMessage()
{
LinkedList msgList = new LinkedList();
/*
To Check COM port Go in following path in Windows7
Control Panel\Hardware and Sound\Bluetooth and Local COM

*/
srv = new CService("COM4",9600,"huawei","E220");//"COM1", 57600, "Nokia", ""
try
{
srv.setSimPin("0000");
srv.setSimPin2("0000");
srv.connect();
srv.readMessages(msgList, CIncomingMessage.MessageClass.Unread);
srv.disconnect();
return msgList;
}
catch (Exception e)
{
e.printStackTrace();
}
System.exit(0);
return msgList;
}
}
Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118

3 Answers3

6

In order to send SMS messages you have two options: either use a gateway modem, or use a bulk service with an online API.

SMSLib is only a library that makes it easier to interface with a gateway (hardware device) or with a bulk SMS provider. Either way, the library by itself is not enough.

The code sample that you provided appears to try to use a gateway connected to a local serial port but since you don't have such a hardware device it's not going to work for you.

Mike Dinescu
  • 54,171
  • 16
  • 118
  • 151
2

One way is to use SMS gateway and send them like ordinary emails.

David Jashi
  • 4,490
  • 1
  • 21
  • 26
1

"I also found that SMSLib code but didn't understand"-

Assuming that you know java/object oriented programming, read through an online tutorial on smslib for understanding the basics. May be you can start with this one http://smslib.org/doc/smslib/quickstart/

Yeasir
  • 39
  • 1
  • 5
  • as already answered by @MikyDinescu, the code sample is definitely using a hardware, probably a huawei E220 modem connected to COM4 port having 9600 baud rate. – Yeasir Jun 11 '13 at 17:20
  • i found that site before but i think it's a general talk, i want something learn me that theoretically and programmaticly – Muhammed Refaat Jun 11 '13 at 17:31