How to use the Jansi library? [closed]
I want to know how to use Jansi to print color in the command prompt on Windows.
From: http://www.rgagnon.com/javadetails/java-0047.html
import org.fusesource.jansi.AnsiConsole;
public class Test {
public static final String ANSI_CLS = "\u001b[2J";
public static final String ANSI_HOME = "\u001b[H";
public static final String ANSI_BOLD = "\u001b[1m";
public static final String ANSI_AT55 = "\u001b[10;10H";
public static final String ANSI_REVERSEON = "\u001b[7m";
public static final String ANSI_NORMAL = "\u001b[0m";
public static final String ANSI_WHITEONBLUE = "\u001b[37;44m";
public static void main(String args[]){
AnsiConsole.systemInstall();
AnsiConsole.out.println(ANSI_CLS);
AnsiConsole.out.println
(ANSI_AT55 + ANSI_REVERSEON + "Hello world" + ANSI_NORMAL);
AnsiConsole.out.println
(ANSI_HOME + ANSI_WHITEONBLUE + "Hello world" + ANSI_NORMAL);
AnsiConsole.out.print
(ANSI_BOLD + "Press a key..." + ANSI_NORMAL);
try {System.in.read();}catch(Exception e){}
AnsiConsole.out.println(ANSI_CLS);
AnsiConsole.systemInstall();
}
}
And do not try to run within eclipse. The colors won't appear on eclipse console. Bundle it in a jar and run it on windows console i.e. command prompt.
For better result try to be more specific when asking questions, like, providing a link to the library which you are referring to and if possible whatever piece of code you have written.
By the way I got that link by just googling: Jansi+ANSI+Color
精彩评论