How to clear the screen in java?

Hi,
How to clear the screen in java without using any loops?
Thanks

Just paint with your background color to let the old paintings vanish.

Similar Messages

  • Does anybody know how to Clear the screen in Java?

    Hi guys,In C we use System Clear.
    In java,which instructions shall i use in order to clear the screen?
    Thanks,in advance!

    Of course you shouldn't do so anyway...
    Terminal programs should coexist with all other terminal programs and not try to dominate the screen.
    They should never clear the screen as this would remove output from other programs running in the same terminal.

  • Clearing the screen using java

    hi
    how to clear the screen using a java program

    for (int n = 0; n < 24; n++) System.out.println();
    Even better: don't clear the screen. The program I ran before your program printed out very important things. If your program throws away those important things then I will not like you or your program.

  • How i can clear the screen in JAVA?, in c++ is  command that called .......

    system("cls")
    but in JAVA??
    thx
    gicio1

    system("cls") is the silly way to do it. For a start, "cls" isn't on most computers, because most computers call it "clear". You could run this from Java using Runtime.exec("clear"), Runtime.exec("cls"), etc .. but the best way to clear the screen is still to print out N newlines, where N is the height of the screen.
    The only problem with this way is, you don't know the height of the screen. You could pass an environment variable in as a system property, from whatever launches your program, and if it's not there "assume" it's 200 or something. Then just build up a string with "\n\n\n\n\n\n\n\n"... and print it out. Blam, blank screen. :-)

  • How to clear the screen in the command prompt?

    Hello Everyone,
    I was wondering how we can clear the screen in the command prompt in Java. I remember we can do this in C by writing system("cls");
    What is the best IDE for writing Java programs. Is the NetBeans IDE good? Thank you very much.

    I was wondering how we can clear the screen in the
    command prompt in Java. I remember we can do this in
    C by writing system("cls");I guess there's no Java way of doing that because it's a function of the shell you're calling. If you try to use Runtime.exec on cls, it starts yet another shell, clears that, and closes it again, so it has no effect on your output.
    You could try using the '\b' backspace character, if that helps.
    What is the best IDE for writing Java programs. Is
    the NetBeans IDE good? Thank you very much.By the way you're asking this question, the answer will be almost certainly "none". If you want to, you can search this board for the few million times this question was asked before, pick all IDEs suggested there and use the one you're most comfortable with.

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

  • How do I clear the screen?

    Hello,
    I would like to know how to clear the screen. What is the code for it?
    Ernest_E

    Hi,
    Look to the left. There is a search field there. This question is often asked. The short answer is that you can't do it.
    /Kaj

  • 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 do I clear the screen in console application?

    In C or C++ we can clear the screen by clrscr() function.
    How can I acheive something similiar to this in Java

    Hi,
    Take a look at the below link may help you
    http://www.codeguru.com/forum/archive/index.php/t-323058.html
    This forum is exclusively related to discussions about Sun java Studio Creator. Henceforth please post these threads to an appropriate forum.
    MJ

  • How do I clear the screen in text mode (cls)

    How do I clear the screen in text mode (cls)
    Thanks,

    Clearing of console is an OS specific command, so
    in case of Windows you should try:
    Runtime.getRuntime().exec("cls");Though it wouldn't help, because exec() will be done as a separate
    process... :)
    Paul

  • How do I clear the Screen Saver?

    How do I clear the Screen Saver from showing the photos on my phone?

    You must have set it to use your photo stream as the screensaver. You can go into settings - screensaver to change to a different source.

  • Clearing the screen, and special characters

    First off, I want to be able to clear the screen between menu selections. I've been told it's hard, but I don't mind, and I DON'T want to just print a whole heap of lines...
    Second, How can I print special "High ASCII" characters, specifically the ones that are used in DOS borders around menus and windows. Unicode values from 2500 - 256C (Hex)
    Ta muchly,
    -Phil-

    It sounds like you want a CURSES library for java. This seems to be a rare thing since once people are willing to go to the effort of using curses, they just use AWT or Swing instead. But I've seen CURSES libraries out there. Try Google.
    If the DOS extended characters are really part of Unicode, then just print out the relevant characters. You can use Unicode escape sequences (\u0000) to do so. This assumes that the terminal can handle them, which it may not.
    You could just print out the terminal escape sequences to clear screen and position the cursor yourself, I suppose, but a CURSES library would probably be more portable.

  • Clearing the screen

    I realize this has probably been covered before but how do you clear the screen of previous lines of code?
    I am using Crimson Editor and the latest SDK and running programs in a DOS shell.
    Please let me know how to do it, if it is a DOS command how to implement into my program and if a java method what the parameters are.
    Thanks.

    If you are wanting to clear the DOS window, there is no provision in Java for that. You could output new lines from your program and force the data on the screed to scroll off.
    The DOS command to clear the screen is "cls" and you will need to use runtime method. Search the forums for that method, there are literally hundreds of posts on the subject. The search is in the upper right corner.

  • Clearing the screen in dos?

    I am executing my programs in DOS and I was wondering if there was a way to clear the screen. I was hoping that this did not involve having JAVA execute DOS commands... But if that is the case, then how do you do that?
    Thanks

    By "the screen" I assume you mean the DOS box where you typed your "java ..." command? If so, the easiest way is to have your Java program execute System.out.println(""); 24 times in a row, or however many times it takes to make it blank. The next time the program writes output, though, it will be at the bottom of the screen. If you don't like that, are really anal, and have nothing better to do you can do some JNI (Java Native Interface aka C++) programming to fix that.

  • How to clear the text in the Text Editor

    Hi all,
    I created a Text editor and also i am having language field in the screen.
    whenever i change the language auomatically the text has to change when the text exists for that
    language.
    this is working fine, but when the Text exist , the text editor should be blank.
    But it is carrying the Previous editor text itself into it .
    How to clear the text in the Editor.
    Regards,
    Madhavi

    Hello Madhavi
    The simple report ZUS_SDN_TEXTEDIT_CONTROL shows how to switch the texteditor contents when changing the language.
    *& Report  ZUS_SDN_TEXTEDIT_CONTROL
    *& Thread: how to clear the text in the Text Editor
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1145272"></a>
    *& By default the itab GT_OUTTAB contains texts in DE and EN.
    *& To switch the language directly enter into the command window:
    *& LANGU=DE, LANGU=EN or LANGU=FR
    REPORT  zus_sdn_textedit_control.
    TYPE-POOLS: abap.
    TYPES: ty_t_text     TYPE TABLE OF as4text
                         WITH DEFAULT KEY.
    TYPES: BEGIN OF ty_s_outtab.
    TYPES: language TYPE spras.
    TYPES: text     TYPE ty_t_text.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab       TYPE ty_t_outtab,
          gs_outtab       TYPE ty_s_outtab.
    DATA: gd_language     TYPE spras.
    DATA: go_docking      TYPE REF TO cl_gui_docking_container,
          go_textedit     TYPE REF TO cl_gui_textedit.
    DATA: gd_okcode       TYPE ui_func,
          gd_repid        TYPE syst-repid.
    START-OF-SELECTION.
      PERFORM fill_texts.
      gd_language = syst-langu.
      PERFORM init_controls.
    * Link the docking container to the target dynpro
      gd_repid  = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      PERFORM set_text_editor.
    * NOTE: dynpro does not contain any elements
      "       ok-code => GD_OKCODE
      CALL SCREEN '0100'.
    * Flow logic of dynpro (does not contain any dynpro elements):
    *PROCESS BEFORE OUTPUT.
    *  MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    *  MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      TRANSLATE gd_okcode TO UPPER CASE.
      CASE gd_okcode.
        WHEN 'BACK'  OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'LANGU=DE' OR
             'LANGU=EN' OR
             'LANGU=FR'.
          PERFORM get_text_editor.
          SPLIT gd_okcode AT '=' INTO gd_okcode gd_language.
          PERFORM set_text_editor.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  FILL_TEXTS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM fill_texts .
    * define local data
      DATA: ld_string   TYPE string.
      gs_outtab-language = 'EN'. REFRESH: gs_outtab-text.
      ld_string = 'Good morning'.
      APPEND ld_string TO gs_outtab-text.
      APPEND gs_outtab TO gt_outtab.
      gs_outtab-language = 'DE'. REFRESH: gs_outtab-text.
      ld_string = 'Guten Morgen'.
      APPEND ld_string TO gs_outtab-text.
      APPEND gs_outtab TO gt_outtab.
      gs_outtab-language = 'FR'. REFRESH: gs_outtab-text.
      ld_string = space.
      APPEND ld_string TO gs_outtab-text.
      APPEND gs_outtab TO gt_outtab.
    ENDFORM.                    " FILL_TEXTS
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
    *      repid                       =
    *      dynnr                       =
    *      side                        = dock_at_left
    *      extension                   = 50
    *      style                       =
    *      lifetime                    = lifetime_default
    *      caption                     =
    *      metric                      = 0
          ratio                       = 90
    *      no_autodef_progid_dynnr     =
    *      name                        =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_textedit
        EXPORTING
    *      max_number_chars       =
    *      style                  = 0
    *      wordwrap_mode          = wordwrap_at_windowborder
    *      wordwrap_position      = -1
    *      wordwrap_to_linebreak_mode = false
    *      filedrop_mode          = dropfile_event_off
          parent                 = go_docking
    *      lifetime               =
    *      name                   =
        EXCEPTIONS
          error_cntl_create      = 1
          error_cntl_init        = 2
          error_cntl_link        = 3
          error_dp_create        = 4
          gui_type_not_supported = 5
          OTHERS                 = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  SET_TEXT_EDITOR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_text_editor .
      BREAK-POINT.
      CLEAR: gs_outtab.
      READ TABLE gt_outtab INTO gs_outtab
           WITH KEY language = gd_language.
      CALL METHOD go_textedit->set_text_as_stream
        EXPORTING
          text            = gs_outtab-text
        EXCEPTIONS
          error_dp        = 1
          error_dp_create = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " SET_TEXT_EDITOR
    *&      Form  GET_TEXT_EDITOR
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_text_editor .
      CLEAR: gs_outtab.
      CALL METHOD go_textedit->get_text_as_stream
        EXPORTING
          only_when_modified     = cl_gui_textedit=>true
        IMPORTING
          text                   = gs_outtab-text
    *      is_modified            =
        EXCEPTIONS
          error_dp               = 1
          error_cntl_call_method = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      MODIFY gt_outtab FROM gs_outtab
        TRANSPORTING text
        WHERE ( language = gd_language ).
    ENDFORM.                    " GET_TEXT_EDITOR
    Regards
      Uwe

Maybe you are looking for

  • Preview - can't select a portion of created PDF

    Hi All, I'm not new the support community (have been able to resolve many an issue by searching), but this is the first time I'm posting. So, I've created a document via Pages and then saved it as PDF (using the print dialog box).  It's a form I use

  • Is not defined in any of the schemas

    i got following error in 10.1.3 while compiling , it is working fine in 10.1.2 bpel_ErrorHandlerBPEL_1.0.jar failed to deploy. Error while loading process. The process domain encountered the following errors while loading the process "ErrorHandlerBPE

  • Copy/create program with logical database

    Hi I need to create a program with the same selection-screen as SAP standard program RPRAPA00. RPRAPA00 is using a logical database, but even that I have passed in the PNP in the attributes of my own progam, I don't get the selection in the top (butt

  • SAP ME 5.2.4 Deployment fails

    Hi, During deployment of SAP ME 5.2.4 I get an error. The details of the error are: Details message(s): Software component ME deployment messages: Deployment of archive seva106\sapmnt\trans\EPS\in\SAPME.sca for component sap.com/ME aborted Detailed m

  • Mac book pro with retina display gets hot

    I have noticed lately that when using my macbook pro with retina display gets really hot when using it - I dont think tis is normal. Or is it? I have had it less that a year and use if for photography editing.