Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

commands in java to clear the screen

Tags:

java

command

What command in Java will let you clear the console in a command-line application?

like image 718
chriss Avatar asked Feb 03 '11 15:02

chriss


2 Answers

If none of the above solutions works for you( as in my case ), try this solution:

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

I'm using Windows 8 and this solution worked for me. Hope it does to you as well. :)

like image 59
Kirankumar Ambati Avatar answered Oct 29 '22 16:10

Kirankumar Ambati


clearing for bash that is working for me:

System.out.print(String.format("\033[H\033[2J"));
like image 44
Alex Avatar answered Oct 29 '22 14:10

Alex