For example, on Win9x installation, you need something like this in the CONFIG.SYS :
device=c:\windows\command\ansi.sys
public class AnsiConsole {
public static void main(String args[]) {
String ANSI_CLS = "\u001b[2J";
String ANSI_HOME = "\u001b[H";
String ANSI_BOLD = "\u001b[1m";
String ANSI_AT55 = "\u001b[10;10H";
String ANSI_REVERSEON = "\u001b[7m";
String ANSI_NORMAL = "\u001b[0m";
String ANSI_WHITEONBLUE = "\u001b[37;44m";
System.out.println(ANSI_CLS);
System.out.println
(ANSI_AT55 + ANSI_REVERSEON + "Hello world" + ANSI_NORMAL);
System.out.println
(ANSI_HOME + ANSI_WHITEONBLUE + "Hello world" + ANSI_NORMAL);
System.out.print
(ANSI_BOLD + "Press a key..." + ANSI_NORMAL);
try {System.in.read();}catch(Exception e){}
System.out.println(ANSI_CLS);
}
}
NT's CMD.EXE does not support ANSI escape sequences. The Good news is that you can use COMMAND.COM instead. To use ANSI.SYS, add the following lines in the CONFIG.NT file:
dosonly device=c:\winnt\system32\ansi.sys
So the only solution left for NT (unless you write some JNI functions, see this HowTo) is to use brute force.
for (int i=0; i<25; i++)
System.out.println();
Written and compiled by Réal Gagnon ©1998-2005
[ home ]