title: Installing a software from Java Projects with sudo command
body: <p>what I would like to achieve is installing a software from java application that  I<br>
      created. I've got permission with gksudo. Then, I typed my pass and the program started 
      working until yes/no option was appeared. How can I pass this question ? </p>
  
  <pre><code>import java.io.IOException;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  
  import java.io.IOException;
  
  
  public class TestApp {
  public static void main(String[] args) {
       Process ls = null;
  
      BufferedReader input = null;
  
      String line = null;
  
      try {
  
          ls = Runtime.getRuntime().exec(
                  new String[] { "gksudo", "apt-get", "install", "PACKAGE" });
          try {
              ls.wait(6000);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          ls = Runtime.getRuntime().exec(new String[] { "y" });
          input = new BufferedReader(new InputStreamReader(
                  ls.getInputStream()));
  
      } catch (IOException e1) {
          e1.printStackTrace();
          System.exit(1);
      }
  
      try {
          while ((line = input.readLine()) != null) {
              System.out.println(line);
          }
  
          ls.destroy();
  
      } catch (IOException e1) {
          e1.printStackTrace();
          System.exit(0);
      }
    }
  
    }
  </code></pre>