GeeCON Prague 2014*
The moose likes General Computing and the fly likes How can I clear the screen in CMD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » General Computing
Bookmark "How can I clear the screen in CMD" Watch "How can I clear the screen in CMD" New topic
Author

How can I clear the screen in CMD

Jahed Hossain
Greenhorn

Joined: Nov 30, 2012
Posts: 11

I'm using Windows 7 and I'm wondering how I can clear the command line screen,
using java code, like normally you would write CLS for Command & Prompt.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

The CLS command works for me in Windows 7. What happens when you type CLS at the command line?

(Also I will move this to the General Computing forum since it isn't about Java.)
Jahed Hossain
Greenhorn

Joined: Nov 30, 2012
Posts: 11

Paul Clapham wrote:The CLS command works for me in Windows 7. What happens when you type CLS at the command line?

(Also I will move this to the General Computing forum since it isn't about Java.)


I'm looking for a statement or something you can write in java to clear the screen.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

What screen?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

You are going to have to invoke some Win32 API functions to do this for you. Which means you need to write a native library to access those functions. This might help:
http://support.microsoft.com/kb/99261?wa=wsignin1.0


JBoss In Action
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

I'd say it should be also possible using either the Jansi, or perhaps JCurses library.

The Jansi library seems to provide platform independent way to do manipulate console output.

JCurses would allow you to create and manage your own console (that's way different from using stdout, but perhaps it might fit your needs too).
 
GeeCON Prague 2014
 
subject: How can I clear the screen in CMD