日期:2014-05-20  浏览次数:20749 次

急问Runtime.getRuntime().exec(command)相关问题?()
我在linux环境下调用一个程序,写法如下      
                ........        
                Process   process   =   null;
                BufferedReader   input   =   null;
                InputStreamReader   in   =   null;
                try   {
                        process   =   Runtime.getRuntime().exec( " ",   null,
                                                                                                new   File(strRootDir));
                        in   =   new   InputStreamReader(process.getInputStream());
                        input   =   new   BufferedReader(in);
                        process.waitFor();
                        return   process.exitValue();
                }   catch   (Exception   e)   {
                        e.printStackTrace();
                        return   1;
                }   finally   {
                      ............
                }
.......

------解决方案--------------------
是环境变量和文本解释器的问题。
你可以写一个.sh文件取调用你的
lha ef /usr/local/mysearch/file/1111111111.lzh
在.sh文件第一行加上#!你的bash的位置。
如果你的bash在/bin/bash
你就写
#!/bin/bash就可以了
然后把需要的环境变量也加进去