Clearing the console screen

I am tring to clear the console screen using java like clrscr() function in c..( cls command in Dos).
Can anyone help me out.

Hi ,
Try this code.
char esc = 27;
String clear = esc + "[2J";
System.out.print(clear);
And this line must be inside the config.sys:
device=c:\windows\command\ansi.sys
Hope this helps.
Roopasri Vittal
Developer Technical Support
Sun Microsystems
http://sun.com/developers/support

Similar Messages

  • How do i clear the  console

    Hi Experts
    I need to know "how do i clear the console " and
    "how do position the mouse cursor in x and y coorditates in a console "
    Thanks in advance

    You don't. Or, it depends on the console. Depending on your point of view.
    Java doesn't directly control it the same way that it controls an AWT window for example. It just sends bytes to it. If the console is capable of interpreting bytes in such a way to clear the screen, then it can.
    Most consoles a person is likely to use will interpret VT100 commands. Look them up; try google. You can just output those commands and the console will do what they say, hopefully.
    Sending a control-L (bye 0x0c, I think) may do it. Try that.
    Or you can try the java curses library.
    All this may be wrong if you mean something by "console" other than what I think you mean.

  • Please tell me e code to clear the dos screen in my program

    please sir/mam if u colud plz elp me to know hoe th clear the dos screen in java and I had tried the code i.e.
    Runtime.getRuntime.exec("cls")
    but it did not worked so plz help me out
    u can mail me at [email protected]

    class ClearScreen
         public static void main(String[] args)
              //  The following code needs ansi.sys added to config.sys
              //  DEVICE=C:\WINDOWS\COMMAND\ANSI.SYS
    //          char esc = 27;
    //          String clear = esc + "[2J";
    //          System.out.print(clear);
              //  this will work in all cases
              for (int i = 0; i < 250; i++)
                   System.out.println();
    }

  • Clearing the console window

    hi,
    I'm currently writing a relatively simple CLI based java program, such that I'm just (for output) using System.out.* type functions...
    anyway, it'd make my application look a fair bit better if I could clear the console where I output the text...
    is this possible (under unix or windoze)? if so, any hints?
    regards,
    Jack

    I haven't tried this myself, but you might try looking at a program called jcurzez.

  • How to clear the DOS screen through java program

    how to clear the DOS screen through java program

    Just some Friday fun. Use the telnet program that comes with Windows and supports VT escape sequences.
    import java.io.*;
    import java.net.*;
    public class AutoTelnet {
         private static Socket s;
         public static void main(String[] args) throws Exception {
              Thread t = new Thread() {
                   @Override public void run() {
                        try {
                             s = new ServerSocket(5555).accept();
                        } catch (IOException ex) {
                             ex.printStackTrace();
              t.start();
              Process p = new ProcessBuilder("cmd", "/C", "start", "telnet", "127.0.0.1", "5555").redirectErrorStream(true).start();
              t.join();
              PrintStream ps = new PrintStream(s.getOutputStream());
              ps.println("Screen will be cleared in 5 seconds");
              ps.println("5");
              Thread.sleep(1000);
              ps.println("4");
              Thread.sleep(1000);
              ps.println("3");
              Thread.sleep(1000);
              ps.println("2");
              Thread.sleep(1000);
              ps.println("1");
              Thread.sleep(1000);
              ps.println("\u001b[2J");
              Thread.sleep(5000);
    }

  • How to Clear the Console in java

    Hello
    i am new to java. in one of my assignment i have to clear the screen
    i have tried the following approaches which are not working , one more thing i am using win xp[ with service pack 2
    i have tried following
    1 passing th eansii escape sequence to output
    2 tried to use the Runtime class
    3 tried the Console class
    4 i want to avoid this system.out.println(" "); in a loop
    now what i have to do can anyone help me
    thanks

    Hello
    i am new to java. in one of my assignment i have to
    clear the screen
    have tried the following approaches which are not
    working , one more thing i am using win xp[ with
    service pack 2
    have tried following
    1 passing th eansii escape sequence to output
    2 tried to use the Runtime class
    3 tried the Console class
    4 i want to avoid this system.out.println(" "); in a loop
    now what i have to do can anyone help me
    thanksIf you want to do this with your standard command shell, the only practical solution would be option 4.
    Or have a look at JCurses, I believe it can do that kind of stuff:
    http://sourceforge.net/projects/javacurses/

  • Clear the selection screen

    In a report, after executing the program,  when the back button is pressed, the selction secren should not contain the previous value.
    Satis

    Hi Sathish,
    1. we have to apply some little logic to do this.
    2. we to use the following concepts :
       export .. to memory id
       imprt .. from memory id
      start-of-selection.
      at selection-screen output.
    3. Just copy paste this in new program.
      (it will CLEAR the fields, after execution
       and pressing BACK button)
    4.
    REPORT  ZAM_TEMP00                              .
    parameters : a(10) type c default 'Hi'.
    parameters : b(10) type c default 'Friend'.
    data : flag type c.
    IMPORTANT
    start-of-selection.
      flag = 'X'.
      export flag to memory id 'FLAG'.
      write :/ 'hello'.
    IMPORTANT.
    at selection-screen output.
      import flag from memory id 'FLAG'.
      if flag = 'X'.
        flag = ''.
        a = ''.
        b = ''.
      endif.
      flag = ''.
      export flag to memory id 'FLAG'.
    regards,
    amit m.

  • Clear the selection screen cached values

    Hello BW gurus,
    Is there a way to clear the contents of the selection screen(cached variable values) whenever it is refreshed?
    Thanks,
    madhuri

    Hi Madhuri,
    Please check this link if any use let me know
    http://help.sap.com/saphelp_crm50/helpdata/en/6e/798e07b33b11d5993800508b6b8b11/frameset.htm
    thanks
    Ranganath

  • The screen on my ipod nano 2nd generation turns black. It still plays music. I've tried resetting the ipod to clear the black screen and the screen goes back to it's normal state but after a few minutes the screen goes black again.

    The screen on my ipod nano, 2nd generation, turns black. It stills plays music. I've tried resetting the ipod to clear the black and the screen goes back to it's original state. But after a few minutes the screen turns black again, while the music is still playing. What can I do about this?

    That's just the iPod's backlight timer going off, signaling the iPod's backlight to turn off to conserve battery power.
    B-rock

  • Clear the console via script?

    Is there a way to clear the Extendscript Toolkit console from the script running?
    Thanks!

    found few lines code about ame-scripting, in japanese
    http://qiita.com/tags/extendscript
    clearing console
    [code]
    var bt = new BridgeTalk();
    bt.target = 'estoolkit-4.0';
    bt.body = function(){
        app.clc();
        }.toSource()+"()";
    bt.send(5);
    [/code]
    That's very interesting. Definitely outside the box thinking.
    thx, David Torno for yours getting started videos
    You're welcome.

  • Clearing the entire screen to see the desktop

    I just upgraded to Lion (10.7.3) this evening and am disappointed that one of my most used features is missing. In OS 10.6.8 (Snow Leopard), I had the ability to do a four-finger swipe upward and clear all windows to see the desktop. I tried that in Lion but it only minimizes the windows (much like Exposé). Is there a feature in Lion that allows me to see the entire desktop with all windows "pushed aside"?

    Make sure your screen resolution is 1024x768 through your control panel.

  • Possible bug: After using page setup in print preview it clears the preview screen and locks up the window (no visible widgets). I have to close the window from the title bar and start the print over.

    On any page, select "Print->Print Preview". Once in the preview window, use the menu to select "Print->Page Setup". In the setup dialog box, click on the "Margins & Header/Footer". Modify some headers and footers. Then click on OK.
    The preview window will either be cleared or become unresponsive. The only way to proceed is to close the preview window using the Windows close button in the top right hand corner. I must then start my printing over.
    I found that I can work around this by first changing the page setup BEFORE going to print preview. However, this looks like a bug and it should be investigated and fixed.

    Both printers? Or just the HP Photosmart C3100 series printer?

  • How to clear the values from a Tab Screen.

    Hi,
    I have created Two Tab in my report by using the below mentioned code.
    SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK BR_ACB WITH FRAME TITLE TEXT-502.
    PARAMETERS: P_VATNUM   TYPE T001-STCEG,
                 P_NAME     TYPE T001-BUTXT,
                 P_STREET   TYPE rfpdo-KQSUSTRAS,
                 P_CITY     TYPE rfpdo-KQSUPADD02,
                 P_CNTRY    TYPE rfpdo-ALLGINLD.
    SELECTION-SCREEN END OF   BLOCK BR_ACB.
    SELECTION-SCREEN END OF SCREEN 200.
    SELECTION-SCREEN BEGIN OF SCREEN 201 AS SUBSCREEN.
    SELECTION-SCREEN BEGIN OF BLOCK br4 WITH FRAME TITLE text-503.
    PARAMETERS: P_IDLU    TYPE LU_IDCODE,
                 P_VATNU   TYPE LU_VATNUM,
                 P_DESIG   TYPE LU_DESIGNATION,
                 p_telf  LIKE rfpdo-asldtelf.       "Telefonnummer
    SELECTION-SCREEN END OF BLOCK br4.
    SELECTION-SCREEN END OF SCREEN 201.
    SELECTION-SCREEN BEGIN OF TABBED BLOCK tabb1 FOR 8 LINES.
    SELECTION-SCREEN TAB (15) tabs1 USER-COMMAND ucomm1 DEFAULT SCREEN 200.
    SELECTION-SCREEN TAB (15) tabs2 USER-COMMAND ucomm2 DEFAULT SCREEN 201.
    SELECTION-SCREEN END OF BLOCK tabb1.
    INITIALIZATION.
      tabs1 = text-500.
      tabs2 = text-501.
    Problem I am facing here is when report loads the screen once and I am filling all the valuse in the Tab Screen 200 and 201 and executing the report and when I am reloading any other variant then it is not clearing the valuse present in the Tab Screen 200 and 201.
    Can any buddy help me regarding this to clear the Tab Screen 200 and 201.
    Thanks and best regards,
    Niteesh Rai

    Hi Niteesh,
    I have tested the scenario which you have mentioned above,  Its working fine for me.
    I have filled all the values in screen 200 and 201 as well and saved it as variant Test1, and again
    I have filled all the values in screen 200 and 201 as well and saved it as variant Test2.
    When I am changing the variants from Test1 to Test2 and vice versa.  I displaying their respective data as well.
    Regards,
    Md Ziauddin.

  • Clear download path in the selection screen

    Hi All,
    Im facing the problem in the selection screen.
    User wants to clear the selection screen download path when they are changing the radio button one to another another radio button. this is as below
    PARAMETERS::pa_werks like ekpo-wekrs,
                             pa_path like string.
    PARAMETERS:rb1 RADIOBUTTON GROUP g01 USER-COMMAND radio,
                  rb2 RADIOBUTTON GROUP g01,
                  rb3 RADIOBUTTON GROUP g01.
    ex:first default is rb1 radio button,so they will select the download path based on F4 help. then they will choose rb2,now the download path has to clear. cause they want choose F4 according to second radio button RB2.
    Thank you very much.
    Anu.

    Hi Anitha,
    Please try this code.
    PARAMETERS: P_FNAME LIKE RLGRAP-FILENAME.
    PARAMETERS:RB1 RADIOBUTTON GROUP G01 USER-COMMAND RADIO,
    RB2 RADIOBUTTON GROUP G01,
    RB3 RADIOBUTTON GROUP G01.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF RB1 = 'X'.
          CLEAR P_FNAME.
        ELSEIF RB2 = 'X'.
          CLEAR P_FNAME.
        ELSEIF RB3 = 'X'.
          CLEAR P_FNAME.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FNAME.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SY-REPID
          DYNPRO_NUMBER = SY-DYNNR
          FIELD_NAME    = 'PATH'
        IMPORTING
          FILE_NAME     = P_FNAME.

  • Clearing of selections screen

    Hi!
    I wanted to asked how to clear a first screen of selections screen ( contains Parameters ans select options )  from another scrren ?
    I created an ALV report. The first screen of the report is a selections screen that contains select options and Parameters. The Alv was created by Object oriented method (not by the function 'reuse_alv_*' ) in
    a second screen. I want from the second screen on certain circumstances to leave the alv screen and to set the first screen ( that contains select options and Parameters ), however when i call the first screen i want to clear all select options and parameters, and my question is how to clear all select options and parameters before i leave to the first screen ?
    thanks
    moshe

    Hi Moshe
    Just I said in my answer you can't do a CLEAR statament in that point of your code, because the system manages the return of old data in selection screen.
    The system do what importing old data from ABAP MEMORY in the event INITIALIZATION, so or you clear the ABAP MEMORY or you clear the selection-screen in the event AT SELECTION-SCREEN OUTPUT.
    You can try this:
    IF g_it_d_data[] IS INITIAL.
    CALL FUNCTION 'POPUP_FOR_INTERACTION'
    EXPORTING
    headline = text-011 " 'Information'
    text1 = text-010
    ticon = 'I' " 'No data was found for
    " the selection criteria.'
    button_1 = 'OK'.
    here i need to clear parameters and selects option
    before leaving to screen 0
    FREE MEMORY.
    LEAVE TO SCREEN 0.
    ENDIF.
    or you place FREE MEMORY statament in INITIALIZATION.
    INITIALIZATION.
    FREE MEMORY.
    You can try to use CLEAR and REFRESH statament in AT SELECTION-SCREEN OUTPUT.
    AT SELECTION-SCREEN OUTPUT.
    Only first time
    CHECK FL_FIRST = SPACE.
    FL_FIRST = 'X'.
    REFRESH <SELECT-OPTION>.
    CLEAR <PARAMETERS>.
    Max

Maybe you are looking for