title: Waiting for process to end in Java
body: <p>So I have this program</p>
  
  <pre><code>    String[] cmd = {"gnome-terminal", "--full-screen", "-e", "./toMatrix"};
      Process p = Runtime.getRuntime().exec(cmd);
      copy(p.getInputStream(), System.out);
      p.waitFor();  
      System.out.println("Exit value = " + p.exitValue());
  </code></pre>
  
  <p>And I want it to run, in another process, the C program toMatrix. But I need it to run in a new terminal window and in full screen mode, so I need to pass those parameters. The problem is that the main process does not wait for the Process p to end. What am I doing wrong?</p>
  
  <p>Regards</p>