无法使用java打开exe应用程序

无法使用java打开exe应用程序,java,processbuilder,Java,Processbuilder,我正在尝试使用java打开Prom(进程挖掘工具)。但它根本没有效果 try { new ProcessBuilder("c:\\Program Files\\Prom\\prom.exe").start() ; } catch (Exception e) { System.out.println(e); e.printStackTrace(); } 此代码无效 但是,当我在同一个文件夹中用相同的代码

我正在尝试使用java打开Prom(进程挖掘工具)。但它根本没有效果

try {
        new ProcessBuilder("c:\\Program Files\\Prom\\prom.exe").start() ;

                } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
    }  
此代码无效

但是,当我在同一个文件夹中用相同的代码打开uninst.exe时,它可以完美地工作

 try {
        new ProcessBuilder("c:\\Program Files\\Prom\\uninst.exe").start() ;

                } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
    }  
我不知道为什么会这样。有什么解决办法吗?
java是否无法加载繁重的应用程序?

您应该通过
进程.getInputStream()
进程.getErrorStream()
检查程序输出,因为程序可能会发出警告或错误消息,这不会导致异常。这些错误或警告通常是因为缺少路径、环境变量、对文件和文件夹的权限或缺少参数

   Process proc = new ProcessBuilder(
                  "c:\\Program Files\\Prom\\prom.exe").start() ;

   BufferedReader stdInput = new BufferedReader(new 
         InputStreamReader(proc.getInputStream()));

    BufferedReader stdError = new BufferedReader(new 
         InputStreamReader(proc.getErrorStream()));

    // read the output from the command
    System.out.println("Here is the standard output of the command:\n");
    while ((s = stdInput.readLine()) != null) {
        System.out.println(s);
    }

    // read any errors from the attempted command
    System.out.println("Here is the standard error of the command (if any):\n");
    while ((s = stdError.readLine()) != null) {
        System.out.println(s);
    }

还应始终使用
process.exitValue()
检查流程的返回代码。按照惯例,零表示一切正常。

您应该通过
进程.getInputStream()
进程.getErrorStream()
检查程序输出,因为程序可能会发出警告或错误消息,这不会导致异常。这些错误或警告通常是因为缺少路径、环境变量、对文件和文件夹的权限或缺少参数

   Process proc = new ProcessBuilder(
                  "c:\\Program Files\\Prom\\prom.exe").start() ;

   BufferedReader stdInput = new BufferedReader(new 
         InputStreamReader(proc.getInputStream()));

    BufferedReader stdError = new BufferedReader(new 
         InputStreamReader(proc.getErrorStream()));

    // read the output from the command
    System.out.println("Here is the standard output of the command:\n");
    while ((s = stdInput.readLine()) != null) {
        System.out.println(s);
    }

    // read any errors from the attempted command
    System.out.println("Here is the standard error of the command (if any):\n");
    while ((s = stdError.readLine()) != null) {
        System.out.println(s);
    }

还应始终使用
process.exitValue()
检查流程的返回代码。按照惯例,零表示一切正常。

运行prom.exe时是否有任何错误或异常?检查您是否有权限执行prom.exe运行prom.exe时是否有任何错误或异常?检查您是否有权限执行prom.exe+1。Process.waitFor()可能有用…我编辑了答案,但我想编辑不被批准。。。您不需要通过
Process.getOutputStream()
检查程序输出,但您在代码示例中的检查是正确的。无论如何+1.@mike自己编辑,谢谢你的建议+1。Process.waitFor()可能有用…我编辑了答案,但我想编辑不被批准。。。您不需要通过
Process.getOutputStream()
检查程序输出,但您在代码示例中的检查是正确的。无论如何+1.@mike自己编辑,谢谢你的建议