Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Redirect cout to System.out as a stream

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

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.

Thanks
Ganesh
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!