I want to call a python program with arguments from java. But my output is a blank. The code is here.
Python code is here:
import sys
print(sys.argv[1])
And the java code is here:
public class PrintNumber{
public static void main(String[] args){
Process proc;
try {
proc = Runtime.getRuntime().exec("python ../pythonProgram/pythonProgram/PrintN.py 30");
BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
proc.waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
I want to output 30, could somebody tell me where is the mistake?