I would like my command line java program to output colored texts into the unix console. I am specifically using gnome-terminal on Ubuntu 10.4.
I am able to get colors with something like echo "\033[01;32m"Hello
on the terminal.
How can I trigger this with java code? Thanks
Syntax: System. out. println(ANSI_COLORNAME + "This text is colored" + ANSI_RESET);
The colors mean nothing, it's just your IDE highlighting different keywords to make your code easier to read.
If you don't care about terminal compatibility, just replace echo
with System.out.println(
above. For example,
System.out.println("\033[01;32mHello\n");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With