user471011
user471011

Reputation: 7386

System.out.print() doesn't send any output to Eclipse console. Why?

I have the following Java class:

public class Test {

    public static void main(String args[]) {

        for (int i = 0; i < 1448; i++) {
            System.out.print(i);
        }

    }
}

When I run this code in Eclipse IDE, I don't see any output in Eclipse console.

If I change value 1448 and set for example 1447 or less, I see output in console (12345678...)

So, maybe Eclipse IDE has restrictions on string length in console?

What do you think about this?

Upvotes: 20

Views: 83412

Answers (5)

Gourab Barenya Sahoo
Gourab Barenya Sahoo

Reputation: 11

Using \t solved my problem.

Example: System.out.println("Result:\t" + data);

Upvotes: 1

Gene
Gene

Reputation: 11285

How to System.out.println out to console: Right click on your glassfish (Server tab) and go to View Log File

enter image description here

Make sure the console setting is directed at your server.log file: enter image description here

Upvotes: 0

Chandra Sekhar
Chandra Sekhar

Reputation: 19500

I tested your code in my copy of Eclipse Helio IDE. It works for smaller number as per your said. But in case of larger number it is actually printing in the consol but the ouput is not displaying. You can see it, if you try to copy and paste it in the coding editor or some other editor like notepad.

If you use println() it will show the output. Instead you can also use print(i+ "\t") to see the output.

Upvotes: 2

Alex Stybaev
Alex Stybaev

Reputation: 4693

Right click on in console -> Preferences... -> check Fixed width console. Now you have auto word wrap and everything shows ok. Seems like Eclipse console have a limit on number of characters displayed in one line.

Upvotes: 26

tykel
tykel

Reputation: 95

According to this, Eclipse does indeed restrict the size of its output buffer.

Of course, you can change this behaviour:

Go to Window > Preferences > Run/Debug > Console and un-check Limit console output; or you can provide any number of characters between 1000 to 1000000.

Edit: It does not seem to fix your problem though.

Upvotes: 10

Related Questions