java调用机器上的shell脚本

java调用机器上的shell脚本,能够这样方便的经过shell脚本调用本机的C、C++等程序java

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) + "毫秒");
相关文章
相关标签/搜索