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. Thanks sir i am understand to jdbc but who will ru
View Tutorial          By: Ranjeet singh at 2012-05-04 07:40:29

2. very good....
View Tutorial          By: satish at 2010-03-03 22:47:25

3. Hi, I tried this code to send sms from my PC which
View Tutorial          By: Jothi at 2009-05-15 03:19:54

4. How can I submit my query in here?
View Tutorial          By: Kafedha Rwezaula at 2010-06-04 01:32:30

5. Hi,

I think this is not a correct d

View Tutorial          By: Dinesh Chopra dc at 2013-03-19 04:30:48

6. the program does run thank you for that .....

View Tutorial          By: VIKRAM at 2007-03-12 13:34:24

7. You should show how to implement a custom sorting
View Tutorial          By: AngleWyrm at 2012-12-13 19:35:30

8. Declaring int result within the method will change
View Tutorial          By: Soph at 2013-02-06 06:11:39

9. how to execute all the 5 files plz tell me step by
View Tutorial          By: asraf at 2007-11-14 22:29:20

10. imgView.setBackgroundResource(R.drawable.ani); i g
View Tutorial          By: mamu at 2012-10-18 14:41:31