JNI: vfprintf hook

A

anton muhin

Hello, gurus!

Old JNI faq (http://java.sun.com/products/jdk/faq/jnifaq-old.html) says:

Note that System.err and System.out are not redirected by the vfprintf
hook. You may call the appropriate Java methods in the System class to
redirect these two Java streams.

If I read it correctly I should use System.setErr and System.setOut
methods, but which object I should pass in?

with the best regards,
anton.
 
G

Gordon Beaton

Old JNI faq (http://java.sun.com/products/jdk/faq/jnifaq-old.html) says:

Note that System.err and System.out are not redirected by the
vfprintf hook. You may call the appropriate Java methods in the
System class to redirect these two Java streams.

If I read it correctly I should use System.setErr and System.setOut
methods, but which object I should pass in?

Pass any open PrintStream to those methods.

If you want to do the redirection from native code instead (which your
question implies), try freopen(), or replace the underlying descriptor
with a combination of open() and dup2(). Or make calls to
System.setOut() etc from the native code.

/gordon
 
A

anton muhin

Gordon said:
Pass any open PrintStream to those methods.

If you want to do the redirection from native code instead (which your
question implies), try freopen(), or replace the underlying descriptor
with a combination of open() and dup2(). Or make calls to
System.setOut() etc from the native code.

/gordon

Thank you!

with the best regards,
anton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top