title: run a java file within another java file and display its output to console
body: <p>i have a <strong>hello world</strong> class hworld.class which displays "Hello World" on the console. i am trying to run it from another class in console using the code   </p>
  
  <pre><code> public class ftest2  
   {  
      public static void main(String[] arg)  
      {  
       System.out.println("NEW FILE PRINT LINE EXECUTED");
        try {  
              Process pro1 = Runtime.getRuntime().exec("javac hworld.java");  
              pro1.waitFor();  
              Process pro2 = Runtime.getRuntime().exec("java hworld");  
              pro2.waitFor();  
           } catch (Exception e) {    
                 System.out.println("Some Error");   
                 e.printStackTrace();     
                  }  
      }  }   
  </code></pre>
  
  <p>but when the file is executed, the output of Hello World is not displayed on the console.<br>
  the program just starts and displays  </p>
  
  <pre><code>  NEW FILE PRINT LINE EXECUTED    
  </code></pre>
  
  <p>insted of   </p>
  
  <pre><code>  NEW FILE PRINT LINE EXECUTED    
    HELLO WORLD    
  </code></pre>
  
  <p>how it would be possible to display the output of HELLO WORLD as well.<br>
  (it is example program. i want to display the output of a program within another program)    </p>
  
  <p>if there is another way to call a class within another class to display its output. then please mention it.</p>