954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Clear the console and/or use system calls

Is there any way to clear the screen in a console app? I noticed that System does not even appear to have a system call similar to the system("COMMAND"); of C++. Any ideas?

dmanw100
Posting Whiz in Training
242 posts since Apr 2008
Reputation Points: 104
Solved Threads: 27
 

You don't own the console, and should NEVER assume that you do.
Therefore you should NEVER try to clear it and should NEVER assume that no other process writes to it.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

There is no direct way to "clear the screen" (except printing out a bunch of blank lines), and yes there is something to the effect of system("COMMAND");

Check out the Runtime and/or ProcessBuilder classes.

But the advice by jwenting is correct.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

Ok thanks! I'll check the Runtime class.. a little more research brought that up too. I'm used to C++ where writing to the console isn't so bad haha

dmanw100
Posting Whiz in Training
242 posts since Apr 2008
Reputation Points: 104
Solved Threads: 27
 

It's just as bad in C++ to assume you own the console.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You