How do you change the colors of Eclipse console using code? I know for red you can use System.err.print("test"); but I want a generalization for any color.
For example, I want a line of one color being blue, another line being magenta, and so on.
How do you change the colors of Eclipse console using code? I know for red you can use System.err.print("test"); but I want a generalization for any color.
For example, I want a line of one color being blue, another line being magenta, and so on.
Generally you cannot change console colors using Java code. Eclipse recognizes "System.err.print" as an error and displays a unique color for that, which is red by default. You can change various defaults in the preferences, but again, there is no Java code that allows you to pick a console output color.
Per Cassio's comment, there are ANSI escape codes to change colors but the console must support it. In order to support it in Eclipse, this plugin is available. https://github.com/mihnita/ansi-econsole