springBoot项目中调用C#编写的exe程序
public static void main(String[] args) {
/**
* id:参数
* path:你TEST_001.exe的路径
*/
Printer printer=new Printer();
Process po = printer.runExe(path+"\\TEST_001.exe",id.toString());//调用runExe方法,路径和参数
int number = po.waitFor();
}
/**
* 执行exe程序
* @param path
* @param params
* @return
*/
public Process runExe(String path,String params) {
Runtime rn = Runtime.getRuntime();
Process p = null;
String[] parm = {path,params};
try {
p = rn.exec(parm);//执行exe
} catch (Exception e) {
System.out.println("Error exec!");
}
return p;
}