0

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は重いアプリケーションをロードできませんでしたか?

4

1 に答える 1

4

プログラムが例外につながらない警告またはエラー メッセージを発行している可能性があるため、Process.getInputStream()および を介してプログラム出力を確認する必要があります。Process.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()。慣例により、ゼロはすべてが正常に完了したことを意味します。

于 2013-09-03T17:08:40.883 に答える