public final class Scripting extends Object
ScriptEngineManager
manager.
Rather than using JDK's ScriptEngineManager
manager directly,
instantiate it via Scripting.createManager()
method. This method is aware
of NetBeans specific runtime configurations. It uses the right classloader
as well as specific discovery mechanisms to locate additional
implementations of ScriptEngineFactory
. To execute a JavaScript
code use:
ScriptEngine
js =Scripting
.createManager().getEngineByMimeType("text/javascript"); assert js != null;Number
x = (Number
) js.eval("6 * 7"); assert x.intValue() == 42;
Consult scripting tutorial to learn more about advanced polyglot scripting topics.
Modifier and Type | Method and Description |
---|---|
static ScriptEngineManager |
createManager()
Create new
ScriptEngineManager configured for the NetBeans
environment. |
public static ScriptEngineManager createManager()
ScriptEngineManager
configured for the NetBeans
environment. The manager serves as an isolated environment -
engines created from the same manager are supposed to share the
same internals and be able to communicate with each other.