Here you can find the source of executeScript(String script)
public static Object executeScript(String script) throws ScriptException
//package com.java2s; /**/*from w ww.j a v a 2 s . co m*/ * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Main { private static ScriptEngine _appleScriptEngine; private static ScriptEngineManager _scriptEngineManager; public static Object executeScript(String script) throws ScriptException { if (_appleScriptEngine == null) { _scriptEngineManager = new ScriptEngineManager(); _appleScriptEngine = _scriptEngineManager.getEngineByName("AppleScriptEngine"); if (_appleScriptEngine == null) { _appleScriptEngine = _scriptEngineManager.getEngineByName("AppleScript"); if (_appleScriptEngine == null) { throw new ScriptException("AppleScriptEngine not available"); } } } return _appleScriptEngine.eval(script, _appleScriptEngine.getContext()); } }