controlling a java program from another
<p>I want to run a Java program from another using <code>ProcessBuilder</code></p>

<p>I used the code</p>

<pre><code>Process pr = rt.exec("cmd /c cd C:\\Users\\naman\\Desktop &amp; java CalculateSum");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
BufferedWriter output= new BufferedWriter(new OutputStreamWriter(pr.getOutputStream()));
String line = null;

while ((line = input.readLine()) != null) {
    System.out.println(line);
}

output.write("10");
output.write("30");

while ((line = input.readLine()) != null) {
    System.out.println(line);
}

int exitVal = pr.waitFor();
System.out.println("Exited with error code " + exitVal);
</code></pre>

<p>CalculateSum has following code:</p>

<pre><code>System.out.print("Enter 1 st value : ");
a=Integer.parseInt(br.readLine());
System.out.print("\nEnter second number : ");
b=Integer.parseInt(br.readLine());
System.out.println("\nresult is : "+(a+b));
</code></pre>

<p>My basic motivation is to run a Java program from another Java program.</p>

<p><strong>NOTE</strong>: I don't want to use command line arguments to take input. Also I have tried using <code>ProcessBuilder</code> for the same purpose, but that also did not work.</p>
