title: How to use clear screen in Java
body: <p>How to clear the screen in Java?</p>
  
  <p>I have created one menu driven simple demo program using while loop and switch case. After one loop completes, I want to clear a screen but that's not working. I will be glad for a possible solution to this.</p>
  
  <p>I am using JDK 7 and running the program in command prompt.</p>
  
  <pre><code>import java.util.*;
  class DemoPrg
  {
      public static void main(String argv[])
      {
          int ch;
          Scanner sc=new Scanner(System.in);
          while(true)
          {
              // i want to clear the scrren hear
              System.out.println("1. Insert New Record");
              System.out.println("2. Display Record");
              System.out.println("3. Delete Record");
              System.out.println("4. Edit Record");
              System.out.println("0. Exit");
              System.out.print("Enter Your Choice:");
              ch=sc.nextInt();
              switch(ch)
              {
                  case 1:
                      System.out.println("insert");
                      break;
                  case 2:
                      System.out.println("display");
                      break;
                  case 3:
                      System.out.println("delete");
                      break;
                  case 4:
                      System.out.println("edit");
                      break;
                  case 0:
                      System.exit(0);
                  default:
                      System.out.println("invalid");
              }
          }   
      }
  }
  </code></pre>