Clearing Command Prompt Window From Program

I am writing a program that runs in the command prompt window. I would like to be able to clear the window prior to updating the status of the program. I know how to do it in C++ but have not yet come across the equivalent command in Java. Does anyone know the command(s)?

Thanks

Comments

  • : I am writing a program that runs in the command prompt window. I would like to be able to clear the window prior to updating the status of the program. I know how to do it in C++ but have not yet come across the equivalent command in Java. Does anyone know the command(s)?
    :
    : Thanks
    :

    Java does not provide any console control in the standard API beyond stdout, stderr and stdin. Your options:
    1) Guess the number of System.out.println() calls you'll need to scroll text off screen
    2) Shell a native command using Runtime.getRuntime().exec()
    3) Use JNI to make a native (eg C++) call
    4) Use a 3rd party console API (I believe there are a few)

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

  • : : I am writing a program that runs in the command prompt window. I would like to be able to clear the window prior to updating the status of the program. I know how to do it in C++ but have not yet come across the equivalent command in Java. Does anyone know the command(s)?
    : :
    : : Thanks
    : :
    :
    : Java does not provide any console control in the standard API beyond stdout, stderr and stdin. Your options:
    : 1) Guess the number of System.out.println() calls you'll need to scroll text off screen
    : 2) Shell a native command using Runtime.getRuntime().exec()
    : 3) Use JNI to make a native (eg C++) call
    : 4) Use a 3rd party console API (I believe there are a few)
    :
    : ---------------------------------
    : [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    :
    :


    would somthing like

    for(int i=0;i<40;I++){
    System.out.println("");
    }
  • : : I am writing a program that runs in the command prompt window. I would like to be able to clear the window prior to updating the status of the program. I know how to do it in C++ but have not yet come across the equivalent command in Java. Does anyone know the command(s)?
    : :
    : : Thanks
    : :
    :
    : Java does not provide any console control in the standard API beyond stdout, stderr and stdin. Your options:
    : 1) Guess the number of System.out.println() calls you'll need to scroll text off screen
    : 2) Shell a native command using Runtime.getRuntime().exec()
    : 3) Use JNI to make a native (eg C++) call
    : 4) Use a 3rd party console API (I believe there are a few)
    :
    : ---------------------------------
    : [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    :
    :


    would somthing like

    for(int i=0;i<40;I++){
    System.out.println("");
    }
  • : : : I am writing a program that runs in the command prompt window. I would like to be able to clear the window prior to updating the status of the program. I know how to do it in C++ but have not yet come across the equivalent command in Java. Does anyone know the command(s)?
    : : :
    : : : Thanks
    : : :
    : :
    : : Java does not provide any console control in the standard API beyond stdout, stderr and stdin. Your options:
    : : 1) Guess the number of System.out.println() calls you'll need to scroll text off screen
    : : 2) Shell a native command using Runtime.getRuntime().exec()
    : : 3) Use JNI to make a native (eg C++) call
    : : 4) Use a 3rd party console API (I believe there are a few)
    : :
    : : ---------------------------------
    : : [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]
    : :
    : :
    :
    :
    : would somthing like
    :
    : for(int i=0;i<=40;I++){
    : System.out.println("");
    : }
    :

  • [code]
    for(int i=0;i<40;i++){
    System.out.println();
    }
    [/code]

    Yes, the above code will do it for a console height of <=40. Most consoles can have variable console sizes (under Windows XP, I set mine to have a height of 50 and a buffer of 1000 lines).

    ---------------------------------
    [size=1]HOWTO ask questions: http://catb.org/~esr/faqs/smart-questions.html[/size]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories