我在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 {
           ............
        }
.......

解决方案 »

  1.   

    上面的process  =  Runtime.getRuntime().exec("",  null, new  File(strRootDir));  应该为
     process  =  Runtime.getRuntime().exec(
    "lha ef /usr/local/mysearch/file/1111111111.lzh",  null, new  File(strRootDir));
    刚才一急,没写完就发上来了!
    具体问题是这样的"lha ef /usr/local/mysearch/file/1111111111.lzh"这个命令,在控制台执行没有问题的,可是在代码中一执行,就会导致子进程阻塞,甚至产生死锁,在控制台能查到此进程一直在执行!!!可等好长时间都没结果!!
    望高手指点阿!!!!
    在线等!!!!!!!
    急急急急急急急
    !!!!!!!
      

  2.   

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