Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to clear console in java ?  RSS feed

 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers,

Is there any method or class in java to clear console screen? like a DOS prompt "cls" is command is use to do this..

Thanks,
 
dinesh Venkatesan
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saif,

In the FAQ section, you can find detailed techniques practiced for clearing the console.
Please check it out.

dinesh.
 
poorna prakash parvathala
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One way of doing is you can call the OS specific clear console command for example "CLS" for DOS/Windows using Runtime.exec().
but that is platform specific :-(
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But: you should NEVER do that, NEVER assume you have the console to yourself.
 
Ranjeet Kr Rai
Greenhorn
Posts: 12
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there no way to clear console in JVM
 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somebody has already said to look for our FAQ.
 
vinayak jog
Ranch Hand
Posts: 83
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is platform independent langauge. Different Operating systems have thier own way of accesing console and clearing console. Java has no direct method for clearing console.

Using dos command like "cls" is one of the solution but it works only on windows. Similarly you need to use "clear" command for linux and so on..

Better not to use any of the above said methods lets stick conventional java
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!