• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirect cout to System.out as a stream

Ganesha Duggirala
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a Java application running on glassfish server on Solaris platform. This Java app makes JNI call to C++ library via System.loadLibrary.

I have cout statements in this c++ library (btw, i can modify the source code of this library) which does not print anything on the glassfish server log. However, if i run a standalone java app from the CLI on Solaris i can see both C++ and Java output without any issues.

Is there anyway I can redirect the cout output to the java app so that it can be printed in the server log file along with System.out? I do not want the entire native output to print at the end of JNI call (I'm able to achieve this but it's not what I want) but rather like a live output or a stream which prints in the java log as and when it encounters cout statement.

If someone can provide sample c++ and java code it would be very helpful.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic