title: Clear the console whith Java
body: <p>I saw this topic: <a href="https://stackoverflow.com/questions/2979383/java-clear-the-console">Java: Clear the console</a> <strong>but does not work in Windows</strong> for me.</p>
  
  <p><strong>I have this code:</strong> </p>
  
  <pre><code>import java.io.IOException;
  
  public class hola {
  public static void limpiar_pantalla() throws IOException {
          String os = System.getProperty("os.name");
  
          if (os.contains("Windows"))
          {
              System.out.println("Win 1");System.out.println("Win 1");
              Runtime.getRuntime().exec("cls");
              //for (int i = 0; i &lt; 50; ++i) System.out.println();
              System.out.println("Win 2");
          }
          else
          {
              System.out.println("Linux 1");
              Runtime.getRuntime().exec("clear");
              //for (int i = 0; i &lt; 50; ++i) System.out.println();
              System.out.println("Linux 2");
          }
  
  }
  public static void main(String[] args) throws IOException {
      hola.limpiar_pantalla();
      }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>This is the Linux output:</strong></p>
  
  <p>Linux 1</p>
  
  <p>Linux 2</p>
  
  <p><strong>and the windows output:</strong></p>
  
  <p>F:\bin>java -jar sacar_systema_java.jar
  Win 1
  Exception in thread "main" java.io.IOException: Cannot run program "cls": Create</p>
  
  <p>Process error=2, El sistema no puede hallar el archivo especificado</p>
  
  <pre><code>    at java.lang.ProcessBuilder.start(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at java.lang.Runtime.exec(Unknown Source)
      at hola.limpiar_pantalla(hola.java:10)
      at hola.main(hola.java:24)
  </code></pre>
  
  <p>Caused by: java.io.IOException: CreateProcess error=2, El sistema no puede hallar el archivo especificado</p>
  
  <pre><code>    at java.lang.ProcessImpl.create(Native Method)
      at java.lang.ProcessImpl.&lt;init&gt;(Unknown Source)
      at java.lang.ProcessImpl.start(Unknown Source)
      ... 6 more
  </code></pre>
  
  <p>F:\bin></p>
  
  <p><strong>basicly cls: command not found</strong></p>
  
  <p><strong>I don' know why does not work.</strong></p>
  
  <p><strong>Can anybody help?</strong></p>