• 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

Console Menu

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am trying to create a console application. I can present the user with a menu, read the choice, do "something" and return to the menu. However, I would rather clear the screen when showing the menu again. Something like "cls". I am using the command line in Windows XP (Start --> Run --> cmd). Currently the output all runs together, unless I put a bunch of println statements in the code, which doesn't look to nice.

I tried putting this line before outputting the menu, but Java didn't like it when I ran the app:

java.lang.Runtime.getRuntime().exec("cls");

With this line Java didn't complain, but didn't clear the screen either...

java.lang.Runtime.getRuntime().exec("cmd /c cls");


Any pointers?

Thanks,
David
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check out our FAQ
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And never go anywhere near Runtime.getRuntime().exec(); until you have read Michael Daconta when Runtime.exec() won't.
 
David Serio
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all for the info. I may just use a JTextArea and use that as my "console".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic