Monday 30 September 2013

SMS through JAVA

How to send SMS using JAVA :


Hello Guys !!! This tutorial shows you that how to send an SMS using Java. All that you need is a mobile phone and Dot Net Framework installed in your PC. You have to download some files for sending SMS using Java Code. The files are listed below :-
  1. Dot Net Framework
  2. jacob.dll
  3. Jacob.jar
  4. Regasm.exe
  5. Tom.dll
You have to download all of these to send sms using java. After finish downloading you have to follow some easy instructions given below to register the libraries for sending sms.

Follow these Instructions :

  1. Put Jocob.dll file in Java/jdk/bin and Java/jre/bin


  2. Set the classpath of the Jacob.jar file.


  3. Open Command Prompt in Administrator mode :- Click on start button then type cmd then do right-click on Command prompt and then click Run as Administrator.

    Note: If you do not open it administrator mode then you are not able to register those libraries.
  4. Register Tom.dll by following commands :-
             1.) cd \*path of tom.dll\* (ENTER)
                  Ex: cd c:\SMS

     2.) regasm tom.dll (ENTER)

     3.) regasm tom.dll /codebase (ENTER)










  • Check the com port of the connected phone modem :- The screen shots are given below to check the com port no.
    Open Control Panel


    Click on Phone & Modem option.

    Choose appropriate country and enter your std code in the first text box then click ok.

    Now open the tab Modems. Here you can find the com port no. of your phone modem (if connected). Here in this case, i will use my com port which is COM13.










  • Put the com port no. in the java program code whereever it is needed.










  • Run the program.


  • JAVA Code for Sending SMS :-

     import com.jacob.activeX.*;  
     import com.jacob.com.*;  
     class SendSMS  
     {  
        public static void main(String arg[])  
        {  
           ActiveXComponent comp = new ActiveXComponent("Tom.General");  
           System.out.println("The Library been loaded, and an activeX component been created");  
           String s="";  
           for(int i=0;i<3;i++)  
           {  
              s=Dispatch.call(comp,"SendSms","COM13,8889762181,SMS sending using java...").toString();  
              if(s.equals("true"))  
                System.out.println("Message send........");  
              else  
                System.out.println("Fail to Send Message..........");  
           }  
        }  
     }  
    


    I hope you will find this post helpful in various JAVA Projects. If you face any difficulty in this post you can ask it by commenting here. i will reply as soon as possible.

    For more java codes................ stay connected  :-)

    4 comments:

    1. Can u please tell How to "Set the classpath of the Jacob.jar file."??

      ReplyDelete
      Replies
      1. did u got the answer how to set the classpath of the jacod.jar file if yes plz tell me also.

        Delete
    2. Yeah same question how to set the class path of the Jacob.jar file????

      ReplyDelete
    3. Great blog very interesting thanks for sharing i really like it.

      SMS Monitoring

      ReplyDelete