Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coloured output in command prompt on windows using java

 
ten lrt
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
lrt
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic