File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Coloured output in command prompt on windows using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Coloured output in command prompt on windows using java" Watch "Coloured output in command prompt on windows using java" New topic

Coloured output in command prompt on windows using java

ten lrt

Joined: Nov 07, 2011
Posts: 1
Hi ,

An urgent help is required. I need to display colored font in command prompt during execution of a java program on Windows Machine. I am unable to do so and while I searched for online help I came across JANSI library.

Is there any other way to print colored output in command prompt on Windows OS using Java ? If yes please respond as soon as possible

Thanks in advance
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3445

JANSI looks promising.

Cursory search yields some utilities on the web that add ANSI support to standard Windows consoles, but you'd still have to output proper ANSI codes. JANSI seems to do both for you, without the need to install third-party software on your machines.

The only other option I can think of would be to use JNI to call native Windows Console API functions. While it might provide some additional options over JANSI (like creating additional consoles, for example), it would definitely be much more difficult and complicated to use.
Greg Charles

Joined: Oct 01, 2001
Posts: 2771

Java curses (jcurses) may be a way to go, and I don't mean just screaming at your Java program (though I also don't necessarily rule that out). The jcurses library gives quite a bit of control over the console window. However, it may be overkill for what you want.
I agree. Here's the link:
subject: Coloured output in command prompt on windows using java
Similar Threads
How to ensure JBOSS server is up or down?
executing java program whose class file is in diff path
Very simple program from Head First is showing no output on print
asterisk in command line parameter converted to something else
JAR with no Command Prompt involved