I get this error when trying to execute applescript from my java application. The code is as follows:
String script = "tell application \"Terminal\" to do shell script \"/System/Library/CoreServices/Menu\\ Extras/user.menu/Contents/Resources/CGSession -suspend\" "; ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("AppleScript"); engine.eval(script);
I get the following error:
Exception in thread "main" javax.script.ScriptException: Expected """ but found unknown token. at apple.applescript.AppleScriptEngine.evalScript(Native Method) at apple.applescript.AppleScriptEngine.eval(AppleScriptEngine.java:342) at apple.applescript.AppleScriptEngine.eval(AppleScriptEngine.java:313) at myTestApp.Main.main(Main.java:25)
Thank you for your attention.
java applescript
Jakir00
source share