I have C code that takes input from the console as,
main() {
int value;
printf("Enter a value");
scanf("%d", &value);
printf("the value is, %d", value);
return;
}
now I compile and create an .exe file. (say test.exe)
After that I want to call that executable file from a java code.
so, I used
public class JavaTest {
static String s=null;
public static void main(String[] args) throws java.io.IOException, java.lang.InterruptedException {
java.lang.Runtime rt = java.lang.Runtime.getRuntime();
System.out.println("start");
java.lang.Process p = rt.exec("test.exe");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
p.waitFor();
System.out.println("done.");
}
}
Obviously, that doesn't work. My question is, how do I pass the integer to the process during runtime? I don't want to pass it as command line parameter.