M
Marteno Rodia
Hello,
In my program, I want to launch another Java program on another JVM...
The way how I try to do it and the problem I experienced is as
follows:
1) Primary is another class in my project and is executable...
2) I try to start its main method in the following way:
Process proc = Runtime.getRuntime().exec("java Primary");
or:
String[] cmdArray = {"java", "Primary"};
Process proc = Runtime.getRuntime().exec(cmdArray);
3) Then I try to read process' streams in a separate thread.
4) In the main thread program stops at proc.waitFor() and execution
doesn't resume...
5) In the "reading" thread, the function which blocks execution is
BufferedReader.readLine() (I would rather expect it to return null in
the worst case... but I have even used the BufferedReader.ready()
method and I believe I wait if the buffer is empty...)
6) Nothing happens, the program can't finish...
I've been already asking about the apporach I use:
http://groups.google.com/group/comp..._frm/thread/11e367a28a0b41fd/9d69aa5ef2e34211
And I know this (very good, in my opinion) article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=1
First, I wanted to test notions of visibility between Java executable
classes when invoking my program both from NetBeans IDE and as a JAR
from command line... But I can't do it (as I described above).
What is wrong in my approach?
Thanks in advance for your help.
MR
In my program, I want to launch another Java program on another JVM...
The way how I try to do it and the problem I experienced is as
follows:
1) Primary is another class in my project and is executable...
2) I try to start its main method in the following way:
Process proc = Runtime.getRuntime().exec("java Primary");
or:
String[] cmdArray = {"java", "Primary"};
Process proc = Runtime.getRuntime().exec(cmdArray);
3) Then I try to read process' streams in a separate thread.
4) In the main thread program stops at proc.waitFor() and execution
doesn't resume...
5) In the "reading" thread, the function which blocks execution is
BufferedReader.readLine() (I would rather expect it to return null in
the worst case... but I have even used the BufferedReader.ready()
method and I believe I wait if the buffer is empty...)
6) Nothing happens, the program can't finish...
I've been already asking about the apporach I use:
http://groups.google.com/group/comp..._frm/thread/11e367a28a0b41fd/9d69aa5ef2e34211
And I know this (very good, in my opinion) article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=1
First, I wanted to test notions of visibility between Java executable
classes when invoking my program both from NetBeans IDE and as a JAR
from command line... But I can't do it (as I described above).
What is wrong in my approach?
Thanks in advance for your help.
MR