Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Bug? Stdout and Stderr mixing on lines of console, in file(A JAVA app that writes to stdout and stderr cannot be tested in ide.)
Bug? Stdout and Stderr mixing on lines of console, in file [message #990507] Wed, 12 December 2012 19:41 Go to next message
David Pickett is currently offline David PickettFriend
Messages: 2
Registered: December 2012
Junior Member
I rewrote an old batch process in JAVA, which made it much shorter and clearer, and it runs fine, but I cannot get usable test output in the ide. The app logs on stderr and writes a data file to stdout, just like most common UNIX commands. Using JDK6, even when I flush() stdout, the bits of stderr output end up in the middle of stdout lines, even in the middle of output from the same System.out.printf() call.

This was a managable problem in UNIX/C, as fflush() forced a kernel call write() of all the buffer, and stderr was entirely unbuffered. Using JDK6, there is uncontrolled buffering or delay on both, perhaps gratuitous parallel output threads providing concurrent I/O, that makes the presentation order indeterminate from run to run. I have no problem with the JDK doing concurrent parallel I/O. The IDE should support a clean view of it.

(Delaying stderr is a bit of a JRE concern, as it suggests that you might never see an informative message written to nominally unbuffered stderrr right before an Exception! Maybe the output is guaranteed? In C, the call 'fprintf( stderr, "XXX %d YYYY %s\n", some_integer_now_7, bad_char_pointer );' always prints "XXXX 7 YYYY " using three write(2,...) calls before getting a SEGV from 'bad_char_pointer'.)

It is not a problem at a shell command prompt, as you can divert stdout, stderr or both to files, pipes or /dev/null. However, the Eclipse IDE "Run Configurations" "Common" tab, "Standard Input and Output" area does not have options to put them on separate windows or files, or suppress either from the Console window or the single output file.

This area should offer options for diversion of the output to two files, with an option to combine them in one file like '2>&1'.

The console mixing is a more subtle problem, since for input prompts a programmer might use either PrintStream. The above area might offer new options to allow you to select which shows up on the console, separately, in place of the one "Allocate Console" check box. I suppose you could present an option to have two console windows, both with keyboard tied to stdin, for convenient, separate viewing of each output.
Re: Bug? Stdout and Stderr mixing on lines of console, in file [message #990907 is a reply to message #990507] Fri, 14 December 2012 19:11 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Have a look at https://bugs.eclipse.org/bugs/show_bug.cgi?id=6036 and its duplicates.
Feel free to file an RFE against JDT/Debug regarding the idea to write to separate files.
I'm not sure though, if separate console views would be feasible.
Re: Bug? Stdout and Stderr mixing on lines of console, in file [message #990914 is a reply to message #990907] Fri, 14 December 2012 19:52 Go to previous message
David Pickett is currently offline David PickettFriend
Messages: 2
Registered: December 2012
Junior Member
An optional second console window for stderr should be pretty simple, and eclipse is not stingy about having a window for each anything! Very Happy But even without that, the IDE should support the preexisting level of ease of a shell prompt - one screen and zero to two files, with the screen showing your choice of nothing, what is on either or both:
xxx                             # Both on console
xxx >outfile                    # Stderr on console, stdout in file
xxx 2>errfile                   # Stdout on console, stderr in file
xxx | tee outfile               # Both on console (stdout delayed), stdout in file
xxx >onefile 2>&1               # Nothing on console, both in one file
xxx 2>&1 >outfile | tee errfile # Both on console (stderr delayed), stderr in file
xxx >outfile 2>errfile          # Nothing on console, each is separate file
xxx 2>&1 | tee onefile          # Both on console (delayed), both in one file

Of course, there are other tools and tricks, such as "tail -f xxxfile &" to reduce latency relative to pipe tee.

From the way my VM runs, both in anything is only good if they are nearly silent or you are very lucky or easy going. While the colors change to say which PrintStream it came from, there is no mark on white space generating characters.

I was stunned that after a System.out.flush(), I could write into the middle of the flushed line using System.err. Could that delay be in the IDE? I need to take my class over to the command line or hp-ux and see hat happens there.
Previous Topic:eclipse crashes during startup with NullPointerException
Next Topic:Juno Service Release 1, j2ee localhost error
Goto Forum:
  


Current Time: Wed Apr 24 23:04:27 GMT 2024

Powered by FUDForum. Page generated in 0.02374 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top