简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM