0

我正在用 Java 创建一个跨平台脚本,它将启动 Flash 并执行一些 JSFL 脚本。

我发现这篇文章Executing JSFL from the Command Line on OS X

从命令行工作

osascript -e 'tell application "Flash" to open posix file "/var/...tmp/sample.jsfl"'

不适用于 Java,如下所示:

String flashExe = "Flash";
String jsflFile = "/var/...tmp/sample.jsfl";

MessageFormat osascriptFormat = new MessageFormat("''tell application \"{0}\" to open posix file \"{1}\"''");
String osascript = osascriptFormat.format(new Object[]{flashExe, jsflFile});
String[] commands = new String[]{"osascript", "-e", osascript};

ProcessBuilder pb = new ProcessBuilder(commands);
pb.start();

问题是:如何在 Mac OS X 上从 Java 启动 Flash?

4

1 回答 1

0

容易...根据这篇文章[HOW TO] 从终端启动应用程序?

String jsflPath = "/var/...tmp/sample.jsfl";    
File jsflFile = new File(jsflPath);
jsflFile.setExecutable(true);
String[] commands = new String[]{"open", jsflFile.getAbsolutePath() };

ProcessBuilder pb = new ProcessBuilder(commands);
pb.start();

或者

String[] commands = new String[]{"open", "-a", "Adobe Flash CS5", jsflFile.getAbsolutePath()};
于 2012-12-06T18:22:06.183 回答