For consoles that don't automatically print stderr in red, you can make a java class that extends output stream to add the ANSI color codes. Making a seperate output stream class and then setting the output with System.setErr(new PrintStream(new ColoredOutputStream(System.err)))
makes it so that even if you call something like e.printStackTrace it will still be red. for example this is what I use:
public class ColoredOutputStream extends OutputStream
{
OutputStream errStream;
red = "\033[31m";
reset = "\033[0m";
public ColoredErrorStream(OutputStream outputStream){
errStream = outputStream;
}
@Override
public void write(int b) throws IOException
{
errStream.write(red.getBytes());
errStream.write(b);
errStream.write(reset.getBytes());
}
@Override
public void write(byte[] b) throws IOException
{
errStream.write(red.getBytes());
errStream.write(b);
errStream.write(reset.getBytes());
}
@Override
public void write(byte[] b, int off, int len) throws IOException
{
errStream.write(red.getBytes());
errStream.write(b, off, len);
errStream.write(reset.getBytes());
}
@Override
public void flush() throws IOException
{
errStream.flush();
}
@Override
public void close() throws IOException
{
errStream.close();
}
}