title: How to clear the screen in java in cmd
body: <p>How to clear the screen in the Java
  loke <code>clrscr()</code> command in c.</p>
  
  <p>I am use the command prompt to run the program.</p>
  
  <p>Please put the code:</p>
  
  <pre><code>class Demo
  {
      public static void main(String[] s)
      {
          //clear scrren hear
          System.out.println("Hello World");
      }
  }
  </code></pre>
  
  <p>Also use Runtime class but thats not work pls give the same code to perform this.</p>
  
  <p>Also using this code but not work:</p>
  
  <pre><code>     import java.io.*;  
         class demo
  {
      public static void main(String[] s)
      {   
          try
  {
      String os = System.getProperty("os.name");
  
      if (os.contains("Windows"))
      {
          Runtime.getRuntime().exec("cls");
      }
      else
      {
          Runtime.getRuntime().exec("clear");
      }
  }
  catch (Exception exception)
  {
  }
          //clear scrren hear
          System.out.println("Hello World");
      }
  }
  </code></pre>