|
Java™ by example!
|
|
|
How do I clear the terminal screen in a Java application?
There are a couple ways to do this. One way is to execute a number of System.out.println's:
You can also use the Runtime object and execute (in Windows):
or call a batch file containing CLS. However, this won't work as it is executed on the newly created process. In Windows, you can send the ANSI escape sequence for CLS to the terminal:
Make sure you have installed the ANSI device driver. To do this, enter this line in your config.sys file:
Finally, you can write a C program that clears the screen and call this method through JNI.
Further Information
Author of answer: Joris Van den Bogaert
Comments
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|