我正在尝试在执行我的java代码期间运行python脚本,因为它将取决于从python脚本接收的输出.到目前为止,我尝试使用jythonc,遗憾的是没有成功,现在我试图使用java Runtime和java Process来执行python脚本.

现在我在尝试调用python脚本时遇到了问题.我觉得它甚至没有调用脚本,因为它需要不到几秒钟才能进入下一页….

问题可能是我如何调用python脚本?我试图通过Web应用程序运行它…

这是我的一些代码:

String run = "cmd /c python duplicatetestingoriginal.py" ;

boolean isCreated = fwr.writeFile(BugFile, GD, 500, true, 5, "LET");

if(isCreated){

try{

r = Runtime.getRuntime();

p = r.exec(run);

BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));

BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

String line = "";

while ((line = stdInput.readLine()) != null) {

System.out.println(line);

}

while ((line = stdError.readLine()) != null) {

errorW.write(line);

}

int exitVal = p.waitFor();

arrayList = fwr.readResults();

}catch(Exception e){

}

}

else{

// troubleshoot....

}

更多推荐

java运行python脚本_用Java运行Python脚本