JNI and native exe output

Welcome evry body,i want to ask if there is any way to get the output of a native exe (written in c) when we run it from a java program using JNI.Thank's.
[176 byte] By [jmeista] at [2007-11-27 5:52:34]
# 1
How did you run the exe from JNI?
bschauwejavaa at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 2
You can pass C/C++ primitives between JNI and Java so what do you mean by "output"? Do you mean command terminal output?
TuringPesta at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 3
> Welcome evry body,> i want to ask if there is any way to get the output> of a native exe (written in c) when we run it from a> java program using JNI.> Are you sure you are not using Process.exec()?
cotton.ma at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 4

> Welcome evry body,

> i want to ask if there is any way to get the output

> of a native exe (written in c) when we run it from a

> java program using JNI.

Yes. But that has nothing to do with Java nor even JNI.

And it is certainly easier to just use one of the exec() methods.

jschella at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 5

Thank you for reply,

I launching my exe using the system() function of C,

i am not using Runtime.exe() because i uncontered a lot of problem, you can take a look here:

http://forum.java.sun.com/thread.jspa?threadID=5165759

I want to get the command terminal output of the C program that i run from JNI to display it in a TextArea of my UI.

It seems to be not obvious, i don't found a solution but we are speaking about some thing similar here:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4994125

http://groups.google.cl/group/comp.lang.java.programmer/browse_thread/thread/83d3ac071e6fcff8/6c4872d1272e77f3#6c4872d1272e77f3

jmeista at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 6

> Thank you for reply,

>

> I launching my exe using the system() function of C,

> i am not using Runtime.exe() because i uncontered a

> lot of problem, you can take a look here:

>

> http://forum.java.sun.com/thread.jspa?threadID=5165759

>

>

> I want to get the command terminal output of the C

> program that i run from JNI to display it in a

> TextArea of my UI.

>

> It seems to be not obvious, i don't found a solution

> but we are speaking about some thing similar here:

>

> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=

> 4994125

> http://groups.google.cl/group/comp.lang.java.programme

> r/browse_thread/thread/83d3ac071e6fcff8/6c4872d1272e77

> f3#6c4872d1272e77f3

I really doubt your problem is not resolvable. I really do. And I don't see how the bug report applies to you either.

Anyway.

The output of the process will be sent to System.out So you'll have to redirect that somewhere back in. You can do this inside your program.

Your C process is the Java process.

Now I think you are saying you are launching Java-> C -> other exe

If this is the case then you need to direct the other exe out though C to standard out.

This seems quite the mess.

cotton.ma at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 7
Thank you for reply,That is what you say, i am launching Java-> C -> other exe
jmeista at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...
# 8

> Thank you for reply,

>

> I launching my exe using the system() function of C,

> i am not using Runtime.exe() because i uncontered a

> lot of problem, you can take a look here:

>

> http://forum.java.sun.com/thread.jspa?threadID=5165759

>

>

Which has nothing to do with java itself.

But regardless, FIRST you must collect the stream output in the C code via some method.

Note doing that is a C problem not a java problem.

So are you doing that? Until you are it is pointless to discuss what needs to be done in java.

jschella at 2007-7-12 15:43:44 > top of Java-index,Java Essentials,Java Programming...