• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

runtime to clear console

 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do i use Runtime class to clear the console?
I have tried runtime.exec("cls) but i get a IO exception.
Any pointers will be appreciated.
kane
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well it depends on your OS. You need to use whatever command works from the propmt on that OS.
This works for NT/Win2000 and I think 98
Runtime.getRuntime().exec( "cmd /c cls" ) ;
Before that (win95) you had to use
Runtime.getRuntime().exec( "command /c cls" ) ;
I am not sure what works for Unix.
This obviously will make the app OS specific, therefore a better bet is just to print out a bunch (maybe 30 or so) of newline characters to the console, which forces the stuff on the console to scroll up.
 
Look! It's Leonardo da Vinci! And he brought a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic