How to Send SMS through Java code in Windows

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 🙂
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
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 -
- Just fill first two options, click OK, after that you will get this window-
- 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-
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
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) :-
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 ! 🙂
