Last updated 2004-06-28 by Roedy
Green ©1996-2004 Canadian Mind Products
Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
You are here : home : Java Glossary : C words : console.
You normally do I/O to the console with System.out.println. For details of how, see the File IO Amanuensis. Mainly the console is used for debugging or crude programs like HelloWorld. There are no cursor positioning or colour commands. In theory you could insert your own ANSI control sequences, but Windows/NT just ignores them, even if you install ANSI.SYS. If your console supports ANSI sequences you could use:
System.out.print( "\033[H\033[2J" );
You can effectively clear the console with a println loop of about 80 lines. This won't clear a log file of course. You can also write to the less-redirectable error log with System.err.println.
Some consoles don't display System.out data, just System.err. It is thus probably best to get in the habit of using System.err.println for debugging output.
You can redirect any output to the console with the usual DOS piping commands, namely > and |. You can also internally redirect System.out to a file with System.setOut, and System.err to a file with System.setErr. If you use 4DOS or 4NT you can redirect stdout with 1> and stderr with 2>.
You can hide the console by using javaw.exe (java without) instead of using java.exe.
In NT or 4NT you can expand the size of the DOS window and make it scrollable. Right click the DOS box shortcut | properties | layout | screen buffer size | height That way you can scroll back and see stuff that has rolled off the screen.
If you are in a browser you have to enable to console before you can see it.
How do you get around this? AWT keystroke events are registered immediately. You can thus accept data in a component. You need to fake a console with a TextArea or similar component.
Peter van der Linden created a set of simple console routines for reading character data in various formats called EasyIn. I seem to recall him also writing a keystroke by keystroke class, but I can find no record of it.
home |
Canadian Mind Products | |||
| mindprod.com IP:[24.87.56.253] | ||||
| Your IP:[80.134.30.163] | ||||
| You are visitor number 5373. | ||||
| Please send errors, omissions and suggestions | ||||
| to improve this page to Roedy Green. | ||||
| You can get a fresh copy of this page from: | or possibly from your local J: drive mirror: | |||
| http://mindprod.com/jgloss/console.html | J:\mindprod\jgloss\console.html | |||