title: Passing values from one java program to another
body: <p>I wrote a Java program that can execute another Java program during runtime. The program is as follows:</p>
  <pre class="lang-java prettyprint-override"><code>import java.io.*;
  
  public class exec {
      public static void main(String argv[]) {
          int i = 5, j = 6, k = 7;
          BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));    
          try {
              InputStreamReader isr = new InputStreamReader(System.in);
              BufferedReader br = new BufferedReader(isr);
              System.out.println(&quot;Enter class name&quot;);
              String s = br.readLine();
      
              Process pro = Runtime.getRuntime().exec(s);
      
              BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
              String line=null;
              while((line = in.readLine()) != null) {
                  System.out.println(line);
              }
              in.close();
          } catch(Exception err) {
              err.printStackTrace();
          }
      }
  }
  </code></pre>
  <p>If I execute this program it will prompt the user to enter any class name (Java program) to execute. This is being done using this piece of code <code>Process pro=Runtime.getRuntime().exec(s);</code>.</p>
  <p>Once the user enters the Java class name, I should be able to pass the values 5,6,7 to the Java class entered by the user. Only one value at a time should be passed and the square of that number should be calculated.</p>
  <p>How can I do this?</p>