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

Discussion in 'Java' started by vikaskumar sharma, Oct 6, 2012.

  1. pls help me.if anyone knows how to clear screen of command prompt in
    java as clrscr() in c language.
    vikaskumar sharma, Oct 6, 2012
    #1
    1. Advertising

  2. vikaskumar sharma

    Jeff Higgins Guest

    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.
    Jeff Higgins, Oct 6, 2012
    #2
    1. Advertising

  3. vikaskumar sharma

    Arne Vajhøj Guest

    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
    Arne Vajhøj, Oct 6, 2012
    #3
  4. vikaskumar sharma

    Jeff Higgins Guest

    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
    Jeff Higgins, Oct 6, 2012
    #4
  5. vikaskumar sharma

    Arne Vajhøj Guest

    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
    Arne Vajhøj, Oct 6, 2012
    #5
  6. vikaskumar sharma

    Jeff Higgins Guest

    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.
    Jeff Higgins, Oct 6, 2012
    #6
  7. vikaskumar sharma

    Real Gagnon Guest

    Real Gagnon, Oct 6, 2012
    #7
  8. 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
    Knute Johnson, Oct 6, 2012
    #8
  9. vikaskumar sharma

    Arne Vajhøj Guest

    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
    Arne Vajhøj, Oct 7, 2012
    #9
  10. 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
    Knute Johnson, Oct 7, 2012
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AHR

    Problem with clrscr()

    AHR, Jan 26, 2004, in forum: C++
    Replies:
    3
    Views:
    8,530
    ensvhiiotus_17
    Aug 7, 2008
  2. Jonathan Mcdougall

    Re: clrscr Compiler Independent functions

    Jonathan Mcdougall, Nov 23, 2004, in forum: C++
    Replies:
    0
    Views:
    353
    Jonathan Mcdougall
    Nov 23, 2004
  3. Dfschweiss
    Replies:
    1
    Views:
    394
    Michiel Salters
    Dec 1, 2004
  4. Michele 'xjp'

    POSIX and getch(), clrscr()

    Michele 'xjp', Jul 20, 2007, in forum: C++
    Replies:
    8
    Views:
    1,366
    Thomas Dickey
    Jul 27, 2007
  5. owl
    Replies:
    2
    Views:
    862
Loading...

Share This Page