0

我正在为我的一位前辈制作的基于 Java 的命令行工具在 Javafx 中制作 GUI。命令行工具是一个两步工具,首先您使用一组特定的配置运行程序,之后需要命令行输入退出程序或进行其他分析。我正在使用以下代码块来运行命令行工具的前半部分:

        button = new Button("Run Proteinarium");
    button.setOnAction( e -> {System.out.println("Running Proteinarium");
    String command = "java -jar Proteinarium-master\\example\\Proteinarium.jar config=Proteinarium-master\\example\\config_SIM.txt";
    try {
        Process process = Runtime.getRuntime().exec(command);

        BufferedReader reader = new BufferedReader(
                new InputStreamReader(process.getInputStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            System.out.println(line);
        }

        reader.close();

    } catch (IOException ex) {
        ex.printStackTrace();
    }

    }
    );

但是,在命令行工具的前半部分运行时单击按钮后,GUI 停止响应。我相信这可能是由于命令行工具的后半部分需要在命令终端中进行额外输入。有关如何解决此问题的任何想法?

我在 Windows 10 上运行它。

4

0 回答 0