For Example
String text = "sample";
System.out.println(text);
I want the text to appear in color RED.Tried java.awt but a bit confusing for me.
For Example
String text = "sample";
System.out.println(text);
I want the text to appear in color RED.Tried java.awt but a bit confusing for me.
In case you are using eclipse... you can use
System.err.println("...");
This will print in red in the eclipse console.
You can change ANSI default color. Lets say you have 2 colors
String Green = "\u001B[32m";
String Defauld = "\u001B[0m";
One string ,
String word="Hello World";
and a printing code
System.out.print(Green + word + Defauld + "the end .");
And it print in Green.I dont know if this works in every system.Works in my Linux
PS:I dont have access in a pc right now could you please try the following in windows??
String Green = "\x1b[31m;
String Defauld = "\x1b[0m";
Another solution is to use JCDP (Java Colored Debug Printer) which works on both Windows and Linux. Response from here https://stackoverflow.com/a/6957561 .
GitHub: https://github.com/dialex/JCDP#downloads
I have just tried the example in IntelliJ on Windows 7 and here's the result: