File abc = new File("D:\\sjhk\\zipDir");
System.out.println(abc.getPath());
String SourcePath="c:\\";
String toPath="D:\\";
String Filename="abc123";
String rarPath="WinRAR.exe";
String cmd=rarPath+" x -ibck -y " + SourcePath +"\\"+ Filename + " "+toPath;
Runtime.getRuntime().exec(cmd);
Process proc;
proc = Runtime.getRuntime().exec(cmd);
if (proc.waitFor() != 0) {
System.err.println("exit value = " +
proc.exitValue());
}
上段代码使用java调用可以正确执行,但是写到tomcat中就不行了,程序异常终止,是不是tomcat有什么安全限制,不能执行外部程序啊,怎么能让tomcat执行。
System.out.println(abc.getPath());
String SourcePath="c:\\";
String toPath="D:\\";
String Filename="abc123";
String rarPath="WinRAR.exe";
String cmd=rarPath+" x -ibck -y " + SourcePath +"\\"+ Filename + " "+toPath;
Runtime.getRuntime().exec(cmd);
Process proc;
proc = Runtime.getRuntime().exec(cmd);
if (proc.waitFor() != 0) {
System.err.println("exit value = " +
proc.exitValue());
}
上段代码使用java调用可以正确执行,但是写到tomcat中就不行了,程序异常终止,是不是tomcat有什么安全限制,不能执行外部程序啊,怎么能让tomcat执行。
解决方案 »
- Jsp + Oracle 如何取回id,报错getInt not implemented for class oracle.jdbc.driver.T4CRo
- Struts+Hibernate+Spring异常
- 如何 用java获取多媒体文件的第一张预览图片
- 菜鸟问题:web层的action中怎么调用业务层?
- 紧急求助:Cannot allocate servlet instance for path
- jsp页面java打印问题 菜鸟急寻高手 SOS
- struts2下ajax返回500,java代码段执行到创建createquery时停止,控制台不报错
- 关于jsp页面跳转时候传中文参数的问题
- 用<jsp:include page=""><jsp:param name="" value="" /></jsp:include>的问题,帮忙解决一下!
- 求书
- 请教一个frameset在不通分辨率下的问题
- 过滤器过滤从DB返回 要在页面显示的数据。。。
在tomcat的默认配置下不能运行外部程序,不知道在哪儿修改配置?