Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear console in Java - Eclipse

How to clear the console after a few statements have been executed/printed in Eclipse. I have used flush() but didn't work though. Just posting the sample code.

System.out.println("execute ");
System.out.println("these set of lines ");
System.out.println("first");

Thread.sleep(2000); // just to see the printed statements in the console
System.out.flush(); // it is not clearing the above statements
like image 549
Chandra Shekhar Avatar asked Dec 25 '22 05:12

Chandra Shekhar


1 Answers

The Eclipse Console does not support the interpretation of the clear screen and other ANSI escape sequences which would be required for that. Also, the ANSI Escape in Console Eclipse plug-in does not support clear screen.

In the upcoming Eclipse IDE 2019-12 (4.14) which will be released on December 18, 2019, the interpretation of the backslash (\b) and carriage return (\r) characters can be enabled in the preferences (see Eclipse 4.14 - New and Noteworthy - Control character interpretation in Console View):

enter image description here

like image 104
howlger Avatar answered Jan 09 '23 07:01

howlger