调用Java的Runtime类来执行python程序
import java.io.*;
/**
* @author developer
* @version 1.0
* @date 2019/10/17 9:34
*/
public class ExcutePython {
public static void main(String[] args) throws IOException, InterruptedException {
String exe = "D:\\ArcGIS10.6\\python.exe";
String command = ".\\excutePython\\python\\LandResourcesEvaluation.py";
String[] cmdArr = new String[] {exe, command};
try {
Process process = Runtime.getRuntime().exec(cmdArr);
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();
}
}
}