+ 1

How to clear console screen in Java?

Its possible in C++ but, I want to clear console screen in Java. Is it possible, if yes how?.

20th Mar 2017, 10:54 AM
Vishal Prajapati
3 Answers
+ 5
Android terminals respond to ANSI escape sequences. To clear the screen, print: chr(27) + "[2J" then put the cursor at 0,0 by printing: chr(27) + "[0;0H" You may combine those into one string.
25th Apr 2017, 4:15 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
Though there is no such support on Java. But other way round by calling relevant OS command like cls or clear if( System.getProperty( "os.name" ).startsWith( "Window" ) ) { Runtime.getRuntime().exec("cls"); //Windows os } else { Runtime.getRuntime().exec("clear"); //Linux based }
20th Mar 2017, 11:52 AM
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender)
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender) - avatar
+ 1
@Decender Mahajan that's doesn't goona work for me as I am using AIDE JAVA COMPILER in Android. Still Thanks
20th Mar 2017, 11:54 AM
Vishal Prajapati