0

I am new to java and I just want to know how to perform the "clear screen" in it just like in C. I am currently using IntellijIdea IDE. So, does it require any sort of plugins? since I have already tried this one:

System.out.print("\033[H\033[2J");
System.out.flush();

This not giving me any result. Actually, this what I am trying to do by implementing the below code:

import java.util.*;

public class ScreenClear {
   public static void main(String[] args) {

       System.out.println("Hello world ");
       System.out.println("New to JAVA PROGRAMMING");
       System.out.println("Please tell me how to clear the screen");
       new Scanner(System.in).nextLine();   // Using like getch 
       System.out.print("\033[H\033[2J");
       System.out.flush();
   }
}

But after executing this I am not getting the desired result. Please provide some tips.

James Z
  • 12,104
  • 10
  • 27
  • 43
  • 1
    The problem is that Intelllij doesn't fully implement ANSI / VT100 escape codes. The duplinks offer a couple of solutions. A third solution is to run your application from the Windows / Linux / MacOS command prompt ... in a console / terminal emulator that has VT100 escape handling enabled. – Stephen C Oct 24 '21 at 10:17

0 Answers0