java mac终端命令,Java开始在新的终端运行命令(Mac OSX版) - 进程生成器运行不正常osascript...

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)

解决方案

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值