java调用机器上的shell脚本

java调用机器上的shell脚本,可以这样方便的通过shell脚本调用本机的C、C++等程序

Process process = null;
Runtime runTime = Runtime.getRuntime();
String shellCmd = "sh xxxxxxxxxxx.sh ";
String shellPath = getSoLibPath();
logger.info("执行shell命令:" + shellCmd);
long startTime = System.currentTimeMillis();
process = runTime.exec(shellCmd, null, new File(shellPath));
int resultCode = process.waitFor();
long endTime = System.currentTimeMillis();
logger.info("耗时=" + (endTime - startTime) + "毫秒");

 

posted @ 2018-02-27 14:26  Peach  阅读(605)  评论(0编辑  收藏  举报