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. recursive programs that ask the user to enter the
View Tutorial          By: siyabonga at 2011-08-10 08:34:44

2. Its really helpfull to me thanks................
View Tutorial          By: AKS at 2013-08-10 06:27:43

3. Nice example. Thank you very much.
View Tutorial          By: vinod at 2012-06-19 11:19:53

4. It is very useful ....Thank U sooo much dear...
View Tutorial          By: Augustine Francis at 2014-06-24 16:55:21

5. Very useful tutorial. But if same code is executed
View Tutorial          By: Jitendra Kumar Mahto at 2011-08-12 15:10:14

6. please explain thread t=new thread(this,name). Wha
View Tutorial          By: Bhavin at 2012-09-28 12:26:55

7. Plz can u give me some more examples of recursion.
View Tutorial          By: Asadullah at 2010-01-23 06:38:58

8. You can save a file from the content of the input.
View Tutorial          By: anne at 2011-11-22 10:50:10

9. Hi friends i am the beginner ..
please guid

View Tutorial          By: Jigar at 2013-05-20 11:04:03

10. Oh, Thanks for your code, but I think you should a
View Tutorial          By: Songokute at 2013-01-29 13:55:13