Below is the code sample which works in command prompt
import java.io.*;
public class ClearDemo
{
public static void main(String args[])throws IOException,InterruptedException
{
System.out.println("Hello ,this is test program");
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
}
}
solved Need some kind of Clearscreen for Java [duplicate]