Writing to std out from Java JNI DLL - output only appear when application exits
We're writing a JNI DLL to wrap a third-party DLL. In our DLL, we're writing debug statements to standard out.
When we use the DLL from our Java application, nothing gets printed to the Java console during the application execution. When the application is closed, all the output from the DLL gets written to the Java console.
We'd like to have the output from the DLL开发者_运维百科 to appear on the Java console as the application is executing, instead of only at the end.
Does anyone know why this is happening, and what can be done to get the output during the application execution?
Try to flush the output. If that doesn't work, pass System.out
into your DLL and use this PrintStream
instead of stdout
.
But fflush(stdout);
should be enough.
精彩评论