How to clear screen (as clrscr in c) in java?

  • Thread starter vikaskumar sharma
  • Start date
V

vikaskumar sharma

pls help me.if anyone knows how to clear screen of command prompt in
java as clrscr() in c language.
 
J

Jeff Higgins

pls help me.if anyone knows how to clear screen of command prompt in
java as clrscr() in c language.
You'll need to call some system specific code.
Google java+clrscr.
 
A

Arne Vajhøj

pls help me.if anyone knows how to clear screen of command prompt in
java as clrscr() in c language.

Use JNI to call clrscr.

Or use exex to call an external CLR command.

Arne
 
A

Arne Vajhøj

And after all that googling simply - don't do it.
Use a proper GUI - it may even look and feel like a text terminal.

And that is good advice!

Arne
 
K

Knute Johnson

pls help me.if anyone knows how to clear screen of command prompt in
java as clrscr() in c language.

There is no similar method in Java. Windows has a command "cls" that
causes the DOS window to be cleared. It is an internal command specific
to Windows. Linux has a "clear" command which scrolls the window up to
clear it.

You could duplicate the Linux style clear command easily enough,
although I don't know of any way to determine how many lines the window
has. It may be possible to use Runtime.exec to issue these commands but
I've never been able to get it to work.

You should take a look at the Console class if you are going to do a
terminal based program.
 
A

Arne Vajhøj

06.10.2012 19:18, Knute Johnson kirjoitti:

Pressing ctrl+l from keyboard clears the Linux console. Maybe
System.out.print(CTRL_L); will do it? I did not test..

Very unlikely.

Typical there is a big difference between input and output.

It is 25 years since I have last seen a half duplex terminal.

Arne
 
K

Knute Johnson

Very unlikely.

Typical there is a big difference between input and output.

It is 25 years since I have last seen a half duplex terminal.

I haven't thought about one in at least that long :).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top