Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to clear screen (as clrscr in c) in java?

Reply
Thread Tools

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

 
 
vikaskumar sharma
Guest
Posts: n/a
 
      10-06-2012
pls help me.if anyone knows how to clear screen of command prompt in
java as clrscr() in c language.
 
Reply With Quote
 
 
 
 
Jeff Higgins
Guest
Posts: n/a
 
      10-06-2012
On 10/06/2012 09:55 AM, vikaskumar sharma wrote:
> 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.
 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      10-06-2012
On 10/6/2012 9:55 AM, vikaskumar sharma wrote:
> 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


 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      10-06-2012
On 10/06/2012 10:58 AM, Jeff Higgins wrote:
> On 10/06/2012 09:55 AM, vikaskumar sharma wrote:
>> 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.

or java+curses

 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      10-06-2012
On 10/6/2012 12:00 PM, Jeff Higgins wrote:
> On 10/06/2012 11:39 AM, Jeff Higgins wrote:
>> On 10/06/2012 10:58 AM, Jeff Higgins wrote:
>>> On 10/06/2012 09:55 AM, vikaskumar sharma wrote:
>>>> 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.

>> or java+curses

> 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


 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      10-06-2012
On 10/06/2012 11:39 AM, Jeff Higgins wrote:
> On 10/06/2012 10:58 AM, Jeff Higgins wrote:
>> On 10/06/2012 09:55 AM, vikaskumar sharma wrote:
>>> 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.

> or java+curses

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

 
Reply With Quote
 
Real Gagnon
Guest
Posts: n/a
 
      10-06-2012
> pls help me.if anyone knows how to clear screen of command prompt in
> java as clrscr() in c language.


One way is to use the Jansi library ( http://jansi.fusesource.org/ ).

See http://www.rgagnon.com/javadetails/java-0047.html

Bye.
--
Real Gagnon from Quebec, Canada
* Java, Javascript, VBScript or PowerBuilder snippets
* http://rgagnon.com/howto.html
* http://rgagnon.com/bigindex.html
 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      10-06-2012
On 10/6/2012 6:55 AM, vikaskumar sharma wrote:
> 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.

--

Knute Johnson
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      10-07-2012
On 10/7/2012 7:14 AM, Donkey Hottie wrote:
> 06.10.2012 19:18, Knute Johnson kirjoitti:
>> On 10/6/2012 6:55 AM, vikaskumar sharma wrote:
>>> 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.

>
> 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


 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      10-07-2012
On 10/7/2012 6:02 AM, Arne Vajh°j wrote:
> On 10/7/2012 7:14 AM, Donkey Hottie wrote:
>> 06.10.2012 19:18, Knute Johnson kirjoitti:
>>> On 10/6/2012 6:55 AM, vikaskumar sharma wrote:
>>>> 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.

>>
>> 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.


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

--

Knute Johnson
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Problem with clrscr() AHR C++ 3 08-07-2008 09:59 AM
POSIX and getch(), clrscr() Michele 'xjp' C++ 8 07-27-2007 03:02 PM
Re: clrscr Compiler Independent functions Dfschweiss C++ 1 12-01-2004 11:38 AM
Re: clrscr Compiler Independent functions Jonathan Mcdougall C++ 0 11-23-2004 07:08 PM



Advertisments