Comment on Tutorial - How to Send SMS using Java Program (full code sample included) By Emiley J.



Comment Added by : Amit Shrivastava

Comment Added at : 2015-01-25 13:48:46

Comment on Tutorial : How to Send SMS using Java Program (full code sample included) By Emiley J.
My code runs smoothly. I have taken some steps for resolving some earlier problems.
Step 1: By the help Of Stackoverflow.com (http://stackoverflow.com/questions/11983764/getting-a-javax-comm-nosuchportexception-when-the-port-exist)

comm.jar should be placed in:

%JAVA_HOME%/lib

%JAVA_HOME%/jre/lib/ext

win32com.dll should be placed in:

%JAVA_HOME%/bin

%JAVA_HOME%/jre/bin

%windir%System32

javax.comm.properties should be placed in:

%JAVA_HOME%/lib

%JAVA_HOME%/jre/lib

Step 2: Run this program to check Port Detection.
import java.io.*;
import java.util.Enumeration;
import javax.comm.*;
public class ListPorts
{
public static void main(String args[]) throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
CommDriver commDriver = null;
String driverName = "com.sun.comm.Win32Driver"; // or get as a JNLP property
commDriver = (CommDriver) Class.forName(driverName).newInstance();
commDriver.initialize();
Enumeration ports = CommPortIdentifier.getPortIdentifiers();
while (ports.hasMoreElements()) {
CommPortIdentifier port = (CommPortIdentifier)ports.nextElement();
String type;
switch (port.getPortType()) {
case CommPortIdentifier.PORT_PARALLEL:
type = "Parallel";
break;
case CommPortIdentifier.PORT_SERIAL:
type = "Serial";
break;
default: /// Shouldn't happen
type = "Unknown";
break;
}
System.out.println(port.getName() + ": " + type);
}
}
}

Step 3: I have paste these four Lines in SerialConnection.java
CommDriver commDriver = null; // line 1
String driverName = "com.sun.comm.Win32Driver"; // // line 2
commDriver = (CommDriver) Class.forName(driverName).newInstance(); // line 3
commDriver.initialize(); // line 4


try {
// System.out.println(parameters.getPortName());
portId = CommPortIdentifier.getPortIdentifier(parameters.getPortName());


Step 4: Changed The Message Center No. in my case Airtel Rajasthan csca="+919829003333";
Step 5: Then I have faced "Time Out at step two". So I have changed the com port in sender.java to Com35. I am using Huawei 3g Dongle.
How to know Com Port- Go to Control Panel->Hardware And Sound->Device Manager->Ports(Com & LPT)
there are two ports were mentioned for Huawei 3g. I firstly used Application Interface But It gives Time Out Error
So I used PC UI Interface(Com35) Then message sent without any problem. Please put These lines in SMSClient.java
public static void main(String args[])
{
SMSClient sms=new SMSClient(1);
sms.sendMessage("+917733853839", "Om");
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. <%!
DateFormat date = DateFormat.getDat

View Tutorial          By: saifuctg at 2011-12-30 22:24:54

2. I run the code . It's good.
View Tutorial          By: Golam Rabbi at 2011-07-12 07:06:00

3. nice one !!! just keep it .. i have learn a lot..
View Tutorial          By: dondon at 2011-07-27 04:43:40

4. Gooooooooooodd !!!
View Tutorial          By: Digvijoyee at 2010-08-30 22:11:31

5. this helps a lot
View Tutorial          By: Ashar at 2010-04-28 04:47:36

6. excellent, very clear, thx!!!
View Tutorial          By: ma at 2010-04-07 07:42:47

7. Can anybody send me the java full code for sending
View Tutorial          By: David at 2010-08-22 22:57:38

8. I am using my NOKIA 2700 classic via blutooth conn
View Tutorial          By: Raheela at 2010-05-06 03:11:36

9. its really helpfull to understand.
View Tutorial          By: rakhi at 2010-08-08 12:45:05

10. that was WMC modem i think not Beetel ADSL 2+ mode
View Tutorial          By: chandu at 2008-12-12 22:05:16