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. FILE:- lpton.pl......
.....................

View Tutorial          By: Prats at 2013-02-02 17:33:40

2. </application>
<uses-permission an

View Tutorial          By: saurabh at 2012-01-17 05:00:21

3. I think 19 floor's code doesn't fix the problem.Al
View Tutorial          By: Benson at 2012-11-28 08:04:26

4. nice article, many thanx :)
View Tutorial          By: Unknown at 2008-10-16 21:09:02

5. Very nice article. Really liked the way it took me
View Tutorial          By: Sandeep at 2010-01-10 09:58:25

6. The code gives the following exception :-
<

View Tutorial          By: waqar at 2012-07-26 17:02:07

7. it would be very helpful if you demonstrated how t
View Tutorial          By: newcoder at 2011-10-24 17:40:25

8. somebody help me doing my case study .. its a rese
View Tutorial          By: lady at 2013-12-25 08:21:03

9. How to connect Oracle java cloud service database(
View Tutorial          By: prakash at 2015-08-27 16:19:04

10. i Want the Flow Chart and code for the mobile Cale
View Tutorial          By: Sudip Khatiwara at 2010-03-15 04:10:41