title: Ways to Clear the Console?
body: <p>I have been on this for a while now, and for the past three days have ripped apart the Internet for ways to effectively clear the console in Java.</p>
  
  <h3>Ways I have seen it "done"</h3>
  
  <p>This way
  <code>for(int x = 0; x!=100; x++){
      System.out.println();
  }</code> Sucks, as you can just scroll up and see the printed statements again.</p>
  
  <p><code>Console.Clear();</code> and all variations of it, have not worked for me.</p>
  
  <p><code>Runtime.getRuntime().exec("cls");</code> has not worked in any cases i have tried to use it in. </p>
  
  <p><em>(I use JCreator to code, I have no idea if this has anything to do with my issue)</em></p>
  
  <p><strong>This way</strong> by joesumbody122, looked interesting:</p>
  
  <pre><code> private static void clearLine()
   {
         Console.Write(new string(' ', Console.BufferWidth - Console.CursorLeft));
   }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>private static void clearLine(int left, int top)
  {    
  
  int pLeft = Console.CursorLeft;
  int pTop  = Console.CursorTop;
  
  Console.setCursorPosition(left, top);
  Console.Write(new string(' ', Console.BufferWidth - Console.CursorLeft));
  
  Console.setCursorPosition(pLeft, pTop);
  }
  </code></pre>
  
  <p>But sadly i could not get it to work for me. It gave me errors that all the methods that he called from Console did not exist. <em><code>java.io.*;</code> was imported</em> His method clears one line specifically, so if someone could get this working, <em>(Again, I use JCreator to code, I have no idea if this has anything to do with my issue)</em> I could see it being looped to clear all the lines.</p>
  
  <p><strong>Ways to make less sucky?</strong></p>
  
  <p>Back to this <code>for(int x = 0; x!=100; x++){
      System.out.println();
  }</code> Is there a way to prevent the user from scrolling up in the command line? To set the cursor to the top left of the prompt? That would make this method a whole lot more useful. </p>
  
  <p><strong>Another Theory</strong></p>
  
  <p>Is there a way to simply tell java to stop printing in one command line, start printing in another, and close the window of the first so it only appears to have cleared the console, but instead created an entirely new one? I have pondered this the last two hours, and in theory it would work, but i don't know if the code to do so even exists.</p>