日期:2014-05-18  浏览次数:20699 次

Tomcat执行winrar进行解压文件??????
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执行。

------解决方案--------------------
看看TOMCAT的LOG文件输出什么错误信息??
------解决方案--------------------
rar的命令行模式应该是rar.exe