2012-12-04 61 views
0

我正在用Java創建一個跨平臺腳本,它將啓動Flash並執行一些JSFL腳本。如何在Mac OS X上從Java啓動Flash?

我發現這篇文章的命令行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(); 

問題是:如何從Jav開始Flash一個在Mac OS X上?

回答

0

容易...根據本文[HOW TO] Launch Application from Terminal?

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()};