Java开始在新的终端运行命令(Mac OSX版) - 进程生成器运行不正常osascript [英] Java starting running command in new terminal (mac osx) - process builder not running osascript properly
问题描述
我想在一个新窗口中创建一个新的进程。我下面的命令<一这个例子href=\"http://stackoverflow.com/questions/989349/running-a-command-in-a-new-mac-os-x-terminal-window\">Running在新的Mac OS X的终端窗口命令(使用Java进程生成器)。我打印出来的结果命令和它的作品,如果我在手动键入它,但是当我运行它,它不会启动新的窗口。
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.
一些简单的 osascript -e'告诉应用程序终端做剧本Java的罐子Test.jar的
不会带来任何东西。
Something as simple as osascript -e 'tell application "Terminal" to do script "java -jar test.jar"'
doesn't bring anything up
样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();
}
它甚至没有弹出一个错误(因为它应该,如果它是在一个新的终端窗口启动Java进程)
It doesn't even bring up an error (as it should if it were starting the java process in a new terminal window)
推荐答案
和往常一样,尽管我花费数小时寻找到我的问题,我觉得傻解决方案,我问堆栈溢出后......不需要周围的单引号告诉应用程序...
。进程生成器做到这一点。呃,如果需要被关闭的问题没有把握。很局部的,但肯定混淆IMO
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
这篇关于Java开始在新的终端运行命令(Mac OSX版) - 进程生成器运行不正常osascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!