I am trying to clear the console in Java using Jansi. I am using macOS, but Jansi should be portable.
Here is the code that I have tried:
AnsiConsole.systemInstall();
System.out.println("Hello... ");
System.out.println(Ansi.ansi().eraseScreen());
System.out.println("... world.");
However, this does not clear the screen. It inserts many new lines and then prints the next line, like this:
Hello...
... world.
How do I clear the screen properly, so that my final output is just the below?
... world.
Maybe you can try by overwriting the world "Hello..." with "...world".
It should be something like this: