-1

Inside of method

new ProcessBuilder("cmd", "/c", "cls").inheritIO().start();

System.out.println("Press enter to continue...");

Back to main method Switch

System.out.println("Blah blah blah");

In both cases my program clears everything, leaving no text to tell the user what to do, but instead a blank terminal. I've also tried creating its own method, but it will still clear text before and after its execution.

  • Possible duplicate of [Java: Clear the console](https://stackoverflow.com/questions/2979383/java-clear-the-console) – Marged Dec 04 '18 at 04:59

2 Answers2

2

You need to wait for the external process to finish. You can do that with Process.waitFor(). Like,

Process p = new ProcessBuilder("cmd", "/c", "cls").inheritIO().start();
p.waitFor(); // <-- wait for p to finish
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
-2

For people with similar future problems, use the answer from above, then put throws IOException, InterruptedException from the method it is called and every method higher up.