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. if a class is declared as abstract and it contains
View Tutorial          By: nagaraj at 2012-04-25 17:12:30

2. I want to using swith with string...
How to

View Tutorial          By: anuj at 2015-03-04 18:22:29

3. I want to know the difference between java and .ne
View Tutorial          By: Jack at 2010-06-10 07:40:35

4. it's very usefull to the users who were in startin
View Tutorial          By: Harichandana at 2013-02-28 04:37:17

5. hiiiiiiii
View Tutorial          By: venkateshwarreddy suravaram at 2010-04-30 23:57:01

6. where do i download the DOM and SAX jar?
View Tutorial          By: David at 2011-11-11 03:04:11

7. thanks excellent explanation!!!!!!!!
View Tutorial          By: divya at 2012-01-01 17:37:32

8. Windows XP
libmySQL.dll in package MySQL5.1

View Tutorial          By: Bingo at 2009-11-07 20:11:52

9. excellent
View Tutorial          By: shamim at 2011-07-08 02:39:31

10. Very cool one, thanks, got the concept clear
View Tutorial          By: black boot at 2010-04-18 08:20:20