File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Want to extend Console. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Want to extend Console." Watch "Want to extend Console." New topic

Want to extend Console.

Nachiket Patel
Ranch Hand

Joined: Sep 16, 2007
Posts: 110
I want to extend functionality of Java Console.
Say want to highlight(color) some words etc.

Is it possible???

As per my knowledge, it is not, because it is suppose to be platform independent. And not all platform provides this functionality (or something like that), but say i want to extend only console in windows (as of now)

How to do??

Any ideas???


Before software can be reusable, it first has to be usable. - Ralph Johnson
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Would that be the public final class Console?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

In a completely platform independent way? No. But you can print ANSI escape codes to print colored text and do some cursor movement on Windows, Linux, and Mac OS X, so for all practical purposes yes, you can.

See here for a table of the escape codes you need. For a Java example: this prints "Hello, World" in red:

System.out.println("\u001b[01;31mHello, World\u001b[00m");

[Jess in Action][AskingGoodQuestions]
Nachiket Patel
Ranch Hand

Joined: Sep 16, 2007
Posts: 110
Thank you for your replies.

Would that be the public final class Console?

I said i want to extend functionality not Console class.

Thanks, Ernest, that's what i am looking for. I want to show colored text, as well as folder navigation using <tab> feature.

I tried, but i don't know,
it prints like this..
←[01;31mHello, World←[00m

I'll try, but if you know, why it is not showing, then let me know.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
There was some discussion on this recently:
I agree. Here's the link:
subject: Want to extend Console.
It's not a secret anymore!