Console print color | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Console print color

How do you get a java console to print text in color?

13th Feb 2018, 3:18 AM
Red
Red - avatar
6 Answers
13th Feb 2018, 3:40 AM
Mickel
Mickel - avatar
+ 1
I think I should ask something important ... Are you using CodePlayground to test this? In this case, SL does not offer support for this. The way in which interpreters/compilers work here is particular: they execute the code and then return it as plain text (unless it is a WEB code) If you are trying to do it in Windows it will not work in the same way (as it is specified in the link that I sent). In this OS you must use an external library for it (inside the thread they quote Jansi and apparently if you have installed a Cygwin environment it will work using ANSI escape codes)
13th Feb 2018, 3:51 AM
Mickel
Mickel - avatar
0
I tried ANSI codes but they only printed a string not changed the color of the text outputted from the console. Is there an important statement I’m missing.
13th Feb 2018, 3:44 AM
Red
Red - avatar
0
I use the eclipse ide
13th Feb 2018, 4:31 AM
Red
Red - avatar
0
In the Eclipse console you will not be able to run ANSI escape codes (or not without a plugin). Unfortunately I do not work with the IDE, so I can not offer much more help.
13th Feb 2018, 4:42 AM
Mickel
Mickel - avatar
0
I figured out how to get eclipse to run ANSI codes. However how do you create an ANSI code that utilizes rgb
13th Feb 2018, 9:55 PM
Red
Red - avatar