This C code could clear screen in Unix-like systems (posix terminals)
printf ("\\e [1;1H\\e[2J");
while Java code causes errors