有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    is there a way to know when the user has closed the application started by java?

    当然,以下是方法:

    1. 使用^{}^{}获得^{}
    2. 通过执行process.start()开始这个过程
    3. 然后调用^{}阻塞,直到外部程序终止

    这在Mac和Windows系统上应该可以正常工作


    示例:

    ProcessBuilder pb = new ProcessBuilder("/usr/bin/emacs");
    
    Process proc = pb.start();     // start external program
    
    proc.waitFor();                // wait for it to terminate
    
    performAnotherTask();