调用的时候一直没有反应,而且 process.waitFor(); 的结果为 1,Java 代码为:
public class Tests {
public static void main(String[] args) {
String[] arguments = new String[] {"python", "/Users/dongguabai/IdeaProjects/spark-plan-visual-inspection/web/src/main/resources/py/test1.py", "huzhiwei", "25"};
try {
Process process = Runtime.getRuntime().exec(arguments);
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
int re = process.waitFor();
System.out.println(re);
} catch (Exception e) {
e.printStackTrace();
}
}
}
找了好久,原来是这里应该要调用我们自己配置的 python,于是修改为: