How to Send SMS through Java code in Windows

July 28, 2012

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 🙂

JAVA SMS SEND CODE Working

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-SMS-Code

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

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

Hyper Termianl Java code setting

 

  • 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

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 Hyper Terminal

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 using Java application interface

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 ! 🙂

JAVA SMS SEND CODE Working
Post Tags: #java application to send sms #java sms send code #pc to mobile jsms java application #send sms without gateway #sms projects java
Amit
Amit is a Software Engineering & Android developer,who really want to share his Android tips & idea to android learner.Hope it will help you in future.Follow Him On

Leave a Reply

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

  1. 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.

      1. when i run this code it gives me error like unsuppported major.minor version 51. can you tell me why this problem occur and what i have to do for this ?

  2. 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.

  3. 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
    [email protected]
    COM1: PORT_OWNED

    what will i do.can you help me

    1. Hi Sruthi, can u please tell us which OS ur using,I mean 32-bit or 64-bit? Win xp or win7? A terminal issue may occur if you are using different lib. Your inputs will help us to solve your query

0 Shares
Share via
Copy link