title: Developing an SMS Sending Application using Java Swing
body: <p>I have a 2 functions in a class:</p>
  
  <ol>
  <li><p><code>login()</code> Logs into a site</p></li>
  <li><p><code>Send_Sms()</code> Sends the  sms</p></li>
  </ol>
  
  <p>Here I am Thinking of putting 2 threads for the functions so that the exceution of the function <code>Send_Sms</code> can be controlled in a manner that it starts to send the sms after the <code>login()</code> has completed successfully otherwise program will not work.</p>
  
  <p>This is what I have done so far :</p>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.Writer;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  
  public class RunThreads extends Thread
  {
      public void Login(String username,String password)
      {
          try
          {
              // creates the batch file for Logging into abc.com server
              Writer output = null;
              String UserAgent = "Mozilla/5.0 (Windows NT 5.1;KM:10.0.2)";
              String postdata = "\"" + "username="+username+ "&amp;password=" + password + "&amp;button=Login" + "\"";
              String MainStream = "c:\\wget.exe --output-document=login.html --user-agent=" + "\"" + UserAgent + "\"" + " --max-redirect=10 --cookies=on --keep-session-cookies --save-cookies=cookie.txt --post-data " + postdata + " http://www.abc.com/Login1.action;";
              File file = new File("login.bat");
              output = new BufferedWriter(new FileWriter(file));
              output.write(MainStream);
              output.close();
              Runtime.getRuntime().exec("cmd /c start login.bat");
          }
          catch (IOException ex)
          {
              Logger.getLogger(Save_Credentials.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
      public void SendSms(String mobno,String content) throws IOException
      {
                  Writer output = null;
                  String UserAgent = "Mozilla/5.0 (Windows NT 5.1;KM:10.0.2)";
                  String MainStream = "c:\\wget.exe --output-document=quicksms.html --user-agent=" + "\"" + UserAgent + "\"" + " --referer=http://www.abc.com/jsp/SMS.jsp --cookies=on --keep-session-cookies --load-cookies=cookie.txt --save-cookies=cookie.txt --post-data "+"\""+"&amp;HiddenAction=instantsms&amp;catnamedis=Birthday&amp;Action=gstahsbdf5346g&amp;chkall=on&amp;MobNo="+mobno+"&amp;textArea="+content+"\""+" http://www.abc.com/quicksms.action;";
                  File file = new File("SendSms.bat");
                  output = new BufferedWriter(new FileWriter(file));
                  output.write(MainStream);
                  output.close();
                  Runtime.getRuntime().exec("cmd /c start SendSms.bat");
      }
      public static void main(String[] args) 
      {
  
  
      }
  }
  </code></pre>