Change color of java console output

后端 未结 4 1737
无人及你
无人及你 2020-12-30 12:14

I was wondering if there is someway for me to set the color of the text that I output to the console in Java. It does not matter if it is system specific as the program will

相关标签:
4条回答
  • 2020-12-30 12:27

    You can take a look at the Java Curses Library: http://sourceforge.net/projects/javacurses/

    Here's an entry on how to use it: http://www.javaworld.com/javaworld/javaqa/2002-12/02-qa-1220-console.html

    0 讨论(0)
  • 2020-12-30 12:29

    Another library you may be interested in is Jansi: http://jansi.fusesource.org/

    Jansi interprets ANSI code and format them for the console output. It works for both unix and windows.

    Update 11/2014: you can also see the github Page

    0 讨论(0)
  • 2020-12-30 12:35

    thy this.... furthermore read http://jansi.fusesource.org/

    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_BLACK = "\u001B[30m";
    public static final String ANSI_RED = "\u001B[31m";
    public static final String ANSI_GREEN = "\u001B[32m";
    public static final String ANSI_YELLOW = "\u001B[33m";
    public static final String ANSI_BLUE = "\u001B[34m";
    public static final String ANSI_PURPLE = "\u001B[35m";
    public static final String ANSI_CYAN = "\u001B[36m";
    public static final String ANSI_WHITE = "\u001B[37m";
    
    0 讨论(0)
  • 2020-12-30 12:36

    Not directly related to Java console output, but if you're looking to use ANSI colors in Kotlin console output, this is a great library to use - https://github.com/importre/crayon

    0 讨论(0)
提交回复
热议问题