D
Dave
Hi,
Just playing around the Runtime.exec function.
Suppose I have a program called Worker.java, which will act as the
sub-process.
import java.io.*;
public class Worker {
public static void main(String[] args) {
try {
PrintWriter loFile = new PrintWriter( new
FileWriter("testout") );
loFile.println("test");
loFile.close();
} catch( Exception e) {
e.printStackTrace();
}
}
}
and the caller Caller.java
public class Caller {
public static void main(String[] args) {
String SC = "java Worker";
// String SC = "touch touchedout";
try {
Process t_proc = Runtime.getRuntime().exec( SC
);
} catch( Exception e) {
e.printStackTrace();
}
}
}
Then after compiled both and ran java Caller, I didn't get the output
file "test" generated by Worker. No errors, no complaints. Nothing. I
have permission on writting to the dir. However, if I use the "touch
touchedout" as the command to be executed by exec, I'll get the output
file.
Is there any limitation that I can't exec another java program?
Thanks a lot.
Just playing around the Runtime.exec function.
Suppose I have a program called Worker.java, which will act as the
sub-process.
import java.io.*;
public class Worker {
public static void main(String[] args) {
try {
PrintWriter loFile = new PrintWriter( new
FileWriter("testout") );
loFile.println("test");
loFile.close();
} catch( Exception e) {
e.printStackTrace();
}
}
}
and the caller Caller.java
public class Caller {
public static void main(String[] args) {
String SC = "java Worker";
// String SC = "touch touchedout";
try {
Process t_proc = Runtime.getRuntime().exec( SC
);
} catch( Exception e) {
e.printStackTrace();
}
}
}
Then after compiled both and ran java Caller, I didn't get the output
file "test" generated by Worker. No errors, no complaints. Nothing. I
have permission on writting to the dir. However, if I use the "touch
touchedout" as the command to be executed by exec, I'll get the output
file.
Is there any limitation that I can't exec another java program?
Thanks a lot.