How to Send SMS through Java code in Windows

17 Flares 17 Flares ×

Now a days SMS is major interactive thing in major mobile application development platform like Android, IOS, Blackberry, Symbain & Bada etc. Developers are re-imagine the way of SMS used previously. So intelligent auto sender SMS apps like ebuddy XSMS, Nimbuzz makes peoples life easier. Now a days SMS is nothing but day to day notification service. If you are a developer then here is a good chance to explore your idea using sms.For this you don’t require to BUY SMS gateways and all.You can use your mobile as middleware to avail free SMS sending service. All actions will be taken from your cell phone & you will  charge only according to your carrier SMS rates icon smile How to Send SMS through Java code in Windows

JAVA SMS SEND CODE How to Send SMS through Java code in Windows

Requirements-

1)      Multimedia mobile with its drivers installed on your computer,you must connect it through USB mode.

2)      rstxSerial.dll file (please copy this dll to your ‘C:WindowsSystem32’ folder)

3)      RXTXcomm.jar file

4)      IDE- Netbeans or Easy Eclipse

java logo How to Send SMS through Java code in Windows

We are all known Netbeans and Eclipse IDE’s but Easy Eclipse for GUI purpose.

Please download required jar and dll files from following link:

Download SMS Sending JAR & DLL files

AT commands-

  • AT commands are instructions used to control a modem. AT is the abbreviation of ATtention. AT commands are also known as Hayes AT commands. There are different views to understand the meanings of “AT”. Some call it “Attention Telephone”, whereas others interpret it as “Attention Terminal” commands.
  • For execution purpose we need hyperterminal. For this run command “hypertrm.exe” .
  • If you are running this command first time you will get the following window -

Send SMS using Java Code Settings How to Send SMS through Java code in Windows

  • Just fill first two options, click OK,  after that you will get this window-

Hyper Termianl Java code setting How to Send SMS through Java code in Windows

 

  • If you are using Windows 7, copy these 3 files from Windows XP:-

1. C: Program Files/Windows NT/hypertrm.exe

2. C: WINODWS/system32/hypertrm.dll

3. C: WINODWS/Help/hypertrm.chm

Create folder “HyperTerminal” in C:/Program Files and paste above files in this folder. Double click on hypertrm.exe and you will get HyperTerminal in Windows 7.

Connection description Window-

  • Type any name you want and click OK.
  • Then see the option of “Connect using”, chose COM port on your mobile device gets connected.
  • (For that Go to Control Panel -> Phone and Modem Options. Then click the Modems tab. In the list box, you can see which COM port the mobile phone is connected to.)
  • Choose it and click OK.
  • You will get following windows, select “Bits per second option as 9600”. Click OK.

COM port properties-

Send SMS Java Code Comp port settings How to Send SMS through Java code in Windows

Type following commands one by one-

  • AT  (hit enter).

(if you don’t see anything on the window, then go to File->Properties->Settings->ASCII Setup->Select check box of “Echo typed characters locally”->Click OK->Click OK.)

  • You will get a response as OK.
  • AT+CMGF=1 (hit enter).
  • AT+CMGS=”**********” ( Replace * by 10 digit mobile number to which you want to send message).
  • You will get greater than symbol like this “ > “
  • Type your message and press ctrl+z key , hit enter after this.
  • The message will be sent.

Download Java Source Code Project from following link

1. Send SMS using Java Source Code

2. For that check following window

On Hyperterminal  command execution

Java SMS send code configration How to Send SMS through Java code in Windows

Enter Mobile Number in Double-Quotes ” “

Please close this window after using commands, because when this instance is present, we can not use it for another purpose.

Snapshots of Application To Send SMS -

(In Eclipse) :-

Send SMS Java interface How to Send SMS through Java code in Windows

How to import existing project into eclipse-

  • Extract project zip file which you downloaded.
  • On eclipse, click File->Import->General->Existing project into workspace->Browse option for Select root directory-> (Suppose you extract file on the Desktop then Desktop will be the root directory , also choose ” Copy projects into workspace”)->click Finish.
  • After that you have to change the COM port number in “GUIToSendMessage.java ” file on line number 87. I have written there “COM15”. You have to change it according to your settings.
  • Run GUIToSendMessage. java file. You will see above window. Type mobile number and enter a message and click on the Send button.  The message will be sent.

How to import existing project into Netbeans-

  • Extract project zip file which you downloaded.
  • On Netbeans, click File->Import Project->Eclipse Project->Chose  option of “ Import Project Ignoring Project Dependencies ”->Browse for “Project To Import”->(here you import your project)->Browse for “Destination Folder”->(It must be your Netbeans default workspace where you store  all your Netbeans projects)->Click “Finish”.
  • After that you have to change the COM port number in “GUIToSendMessage.java ” file on line number 87. I have written there “COM15”. You have to change it according to your settings.
  • Run GUIToSendMessage. java file. You will see above window. Type mobile number and enter a message and click on the Send button.  The message will be sent.

If you are facing any problem with this code then let us know our team will help you to fix your problems ! if you develop any cool application using this code then do share with us our readers appreciate your development ! icon smile How to Send SMS through Java code in Windows

17 thoughts on “How to Send SMS through Java code in Windows

  1. Thanks nice post.I am not a good programmer , didn’t understand clearly , let me give some more setails
    Sibin recently posted..How to check whether the sites you visit daily contains virus/malwaresMy Profile

  2. hi

    first of all i would say that you described it in very easey language and paragraph by paragraph with diagram.

    i will use this code after completed java. i am persuing java

    thanks

  3. I did all the setup but i was get a following Error:-

    java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
    Exception in thread “AWT-EventQueue-0″ java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path

    where is the exactly problem.?
    Thanks in advance.

  4. I did all set up properly. I solve all the issues also. I get an sms also. But now I was facing a small problem. SMS is come Like this,

    mare tATZ
    AT+CREG?
    AT+CMGF=1AT+CMGS=”mobile number”
    Message

    Now the problem is that , I can not able to send only a message. AT commands also send along with that Message. And sometimes, It is not giving FULL sms. It is escaping some part of the SMS. What should I do?

    Thanks in advance….

    You did a great job.

    Please reply if you know.

  5. hi,
    Actually you post is very nice and helpfull..
    i am doing my project thst to send the sms from PC connected with mobile/gsm modem to another mobile….but when i run your code the messege not sending the output is..

    actionPerformed()
    Stable Library
    =========================================
    Native lib Version = RXTX-2.1-7
    Java lib Version = RXTX-2.1-7
    gnu.io.CommPortIdentifier@f3d6a5
    COM1: PORT_OWNED

    what will i do.can you help me

  6. HI ..

    Program is very good and running well..But , is there a way to send multiple recepients or a kind of a loop ..??

    Thanks..

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge