Results 1 to 5 of 5
  1. #1
    novice is offline Member
    Join Date
    May 2010
    Posts
    30
    Rep Power
    0

    Default colored text with System.out.println

    How to print colored text with System.out.println in Eclipse REGULAR CONSOLE window?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default

    You can't.

    db

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,450
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by novice View Post
    How to print colored text with System.out.println in Eclipse REGULAR CONSOLE window?
    You can set the colours of the text produced by the standard output and standard error streams but you can't set the colour for each individual character in Eclipse's console. Setting colours is highly terminal dependent anyway (what if you have a simple black and white terminal?)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    novice is offline Member
    Join Date
    May 2010
    Posts
    30
    Rep Power
    0

    Default

    Integer i=0;
    while (i<100) {
    i++;
    System.out.println(i.toString());
    System.err.println("error");

    }

    System.err.println("error") works partially BUT
    problem is, the above function first prints 1 to 100 (black) and then it prints 100 times 'error' in red color. Is there any way, that it respects the execution order. I mean, first it print 1 then error then 2 then error and so on.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,450
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by novice View Post
    Integer i=0;
    while (i<100) {
    i++;
    System.out.println(i.toString());
    System.err.println("error");

    }

    System.err.println("error") works partially BUT
    problem is, the above function first prints 1 to 100 (black) and then it prints 100 times 'error' in red color. Is there any way, that it respects the execution order. I mean, first it print 1 then error then 2 then error and so on.
    Try a System.out.flush() and System.err.flush() after each and every println( ... ) call and see what happens.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 8
    Last Post: 06-21-2011, 02:21 PM
  2. Println VS system.out.println
    By ccie007 in forum New To Java
    Replies: 2
    Last Post: 05-20-2010, 08:52 AM
  3. difference between system.out.println() & out.println()
    By wickedrahul9 in forum Advanced Java
    Replies: 5
    Last Post: 10-18-2008, 11:06 PM
  4. System.out.println
    By sunjavaboy in forum Advanced Java
    Replies: 3
    Last Post: 03-22-2008, 01:30 AM
  5. Replies: 2
    Last Post: 08-10-2007, 12:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •