1

I want to clear the console output of the NetBeans console. We can clear it manually by using Ctrl+L.

Is it possible to do this programmatically, in Java?

Thank you very much

Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
Amith
  • 1,907
  • 5
  • 29
  • 48
  • 2
    http://stackoverflow.com/questions/11818991/clear-the-console-programmatically-in-java – Zaki Aug 17 '12 at 09:58

2 Answers2

0

I think that it's not so simple.

The Netbeans console is not really a full system console.

I'd see a proper option - like getting the console reference using the Netbeans RPC binding, but your application would need to run as a Netbeans plugin or bundle. (so - don't do that, keep it simple)

For a shortcut (workaround) - you may try to use java.awt.Robot class to send a keyRelease event (Ctrl+L) while being focused in the console (effectively sending the Ctrl+L event to the focused component)

gusto2
  • 11,210
  • 2
  • 17
  • 36
0

This is a poor solution because it doesn't actually clear anything, but it does push it out of the way to hopefully make it more readable.

System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

add or subtract "\n" to lengthen or shorten it depending on the size of the console window.

JRob369
  • 1
  • 2