Java starting running command in new terminal (mac osx) - process builder not running osascript properly

穿精又带淫゛_ 提交于 2019-12-11 02:22:22

问题


I'm trying to create a new process in a new window. I'm following this example for the command Running a command in a new Mac OS X Terminal window (using Java Process builder). I printed out the resulting command and it works if I type it in manually, but it doesn't start the new window when I run it.

Something as simple as osascript -e 'tell application "Terminal" to do script "java -jar test.jar"' doesn't bring anything up

Sample code:

    try {
        ProcessBuilder pb = new ProcessBuilder("osascript", "-e",
            "'tell application \"Terminal\" to do script \"java -jar test.jar\"'");
        Process p = pb.start();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

It doesn't even bring up an error (as it should if it were starting the java process in a new terminal window)


回答1:


And as usual although I spend hours looking into my problem I find the silly solution after I ask stack overflow... don't need the single quotes around tell application.... Process builder does that. Er, not sure if question needs to be closed. Quite localized, but certainly confusing IMO



来源:https://stackoverflow.com/questions/15714870/java-starting-running-command-in-new-terminal-mac-osx-process-builder-not-ru

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!