0
点赞
收藏
分享

微信扫一扫

Java 调用 Python 没反应

小猪肥 2022-12-22 阅读 137



调用的时候一直没有反应,而且 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,于是修改为:

Java 调用 Python 没反应_spark

举报

相关推荐

0 条评论