java 调用linux脚本例子
public void startTomcat()
{
String currentPath = ServletActionContext.getServletContext()
.getRealPath(File.separator + "WEB-INF" + File.separator);
String tomcatBin = currentPath.split("webapps")[0] + "bin";
String[] commands = {"sh", "startup.sh"};
try
{
ProcessBuilder b = new ProcessBuilder(commands);
b.redirectErrorStream();
b = b.directory(new File(tomcatBin));
Process rt = b.start();
rt.waitFor();
}
catch (IOException e)
{
}
catch (InterruptedException e)
{
}
}