views:

1550

answers:

2

Question is simple:

How can I color java output?

For example in C and other languages I can use ansi-escape like \033[0m to do this. But in java it doesn't work.

public static void main(String[] x) {
    System.out.println("\033[0m BLABLA \033[0m\n");
}
+3  A: 

No, but there are third party API's that can handle it

http://www.javaworld.com/javaworld/javaqa/2002-12/02-qa-1220-console.html

Edit: of course there are newer articles than that one I posted, the information is still viable though.

Jonas B
+1  A: 

Escape sequences must be interpreted by SOMETHING to be converted to color. The standard CMD.EXE used by java when started from the command line, doesn't support this so therefore Java does not.

Thorbjørn Ravn Andersen
if you're running on a non-windows OS there's a good chance that the terminal app will do escape sequence interpretation.
Jherico