LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   java using color with System.out?? (https://www.linuxquestions.org/questions/programming-9/java-using-color-with-system-out-279498/)

caged 01-18-2005 07:38 PM

java using color with System.out??
 
Hi.

Does anyone know a way of using System.out.println("whatever") so that i can define the color of the string output to the screen?

cheers.
Ben.

jlliagre 01-19-2005 01:58 AM

Assuming your terminal emulator is accepting ansi color sequences, which is nowadays almost always the case, you can send escape sequences that change the foreground and background colors.

e.g.: System.out.println("\033[31m\033[44mHello world\033[0m\n");


All times are GMT -5. The time now is 01:27 PM.