title: how to compile & run java program in another java program?
body: <p>I have a Main.java and Test.java classes that I want to compile and run Main.java in Test.java code. Here is my code</p>
  
  <pre><code>    Process pro1 = Runtime.getRuntime().exec("javac Main.java");
      pro1.waitFor();
      Process pro2 = Runtime.getRuntime().exec("java Main");
  
      BufferedReader in = new BufferedReader(new InputStreamReader(pro2.getInputStream()));
      String line = null;
  
      while ((line = in.readLine()) != null) {
          System.out.println(line);
      }
  </code></pre>
  
  <p>I just print "ok" in Main.java but this code doesn't print anything. What is the problem ?</p>