Sending SMS using java code and Clickatell API

ClickatellSMS .java

/**
 * For executing the code you may need the following requirements 1. Clickatell
 * account : You may have a user name, password and an API id. 2. Need to import
 * two external jar files i. smsj-20051126.jar (Source :
 * https://sourceforge.net/projects/smsj/files/) ii. slf4j-simple-1.0-beta4.jar
 * (Source :
 * http://www.findjar.com/jar/org/slf4j/slf4j-simple/1.0-beta4/slf4j-simple
 * -1.0-beta4.jar.html;jsessionid=74226B10CDFB28C183745181681836C7)
 */


import java.io.IOException;
import java.util.Properties;

import org.marre.sms.SmsAddress;
import org.marre.sms.SmsException;
import org.marre.sms.SmsTextMessage;
import org.marre.sms.transport.SmsTransport;
import org.marre.sms.transport.SmsTransportManager;

public class ClickatellSMS {

/**
* @param args
*/
public static void main(String[] args) {
// The username, password and apiid is sent to the clickatell transport
// in a Properties
Properties props = new Properties();

props.setProperty("smsj.clickatell.username", "UserName");
props.setProperty("smsj.clickatell.password", "Password");
props.setProperty("smsj.clickatell.apiid", "API ID");

// Load the clickatell transport
SmsTransport transport = null;
try {
transport = SmsTransportManager.getTransport(
"org.marre.sms.transport.clickatell.ClickatellTransport",
props);
} catch (SmsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// Connect to clickatell
try {
transport.connect();
} catch (SmsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// Create the sms message
SmsTextMessage textMessage = new SmsTextMessage(
"A sample SMS sending tru net. Sajeev.");

// Send the sms to "461234" from "461235"
try {
transport.send(textMessage, new SmsAddress("CC461234"),
new SmsAddress("CC461235"));  // CC means the Country Code
System.out
.println(" transport.send(textMessage, new SmsAddress('918089360844'), new SmsAddress('919847833022'));");
} catch (SmsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// Disconnect from clickatell
try {
transport.disconnect();

System.out.println(" transport.disconnect();");
} catch (SmsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}