使用进程构建器启动可运行的 jar

Start runnable jar with process builder

如何在进程构建器中编写此命令。我尝试了不同的组合,但没有任何效果。

/Users/rawfodog/Documents/OpenJRE11/Contents/Home/bin/Java -jar --module-path /Users/rawfodog/Downloads/AllLibrary --add-modules=javafx.controls,javafx.fxml /Users/rawfodog/Downloads/app.jar

编辑

我的代码:

        ProcessBuilder pb = new ProcessBuilder("/Users/rawfodog/Documents/OpenJRE11/Contents/Home/bin/Java", "-jar", "--module-path /Users/rawfodog/Downloads/AllLibrary","--add-modules=javafx.controls,javafx.fxml", "/Users/rawfodog/Downloads/app.jar");
        pb.start();

您应该将每个单独的参数分开 - 目前 2 个参数加入到“--module-path”参数中:

ProcessBuilder pb = new ProcessBuilder(
  "/Users/rawfodog/Documents/OpenJRE11/Contents/Home/bin/Java"
   , "-jar"
   , "--module-path"
   , "/Users/rawfodog/Downloads/AllLibrary"
   ,"--add-modules=javafx.controls,javafx.fxml"
   , "/Users/rawfodog/Downloads/app.jar");

同时添加代码来检查退出状态/等待进程结束:

Process p = pb.start();
int rc = p.waitFor();