Ishay Frenkel
Ishay Frenkel

Reputation: 319

Change output text color in java

I'm trying to change the color of specific text in Eclipse's console, for example: regular text is in black, but errors are presented in red color. I'm trying to do the same with the try and catch blocks. Here's my code:

int [] arr = {1,2,6,8};

try {
    for (int i = 0; i < 9; i++) {
        System.out.println(arr[i]);
    }
} catch (Exception ArrayIndexOutOfBoundsException) {
    **System.out.println("You got too long");**
}

Now I want the code surrounded by double asterisks to be in red color in the console, is it possible? and if yes then how? Thank you.

Upvotes: 2

Views: 3607

Answers (2)

Youssef Sadiki
Youssef Sadiki

Reputation: 164

Open Preferences -> C/C++ -> Build -> Console and then change the colors as you like.

Upvotes: 2

Chandrayya G K
Chandrayya G K

Reputation: 8859

You can use grep console plugin for this. Check here for more details

You can also filter/color eclipse console text based on regular expression.

Upvotes: 1

Related Questions