Scripts can be executed from within java in the JVM. Let us take javascript language for this example. There are couple of important classes in this package and they are,
ScriptEngineManager and ScriptEngine.
ScriptEngineManager: It has 2 roles
1) Discovery of Script Engine.
2) Storing data in context. (This is shared across programs)
ScriptEngine:
This is an interface available in javax.script. Here we have to specify the scripting language.
You can access source code from below link.
https://bitbucket.org/nkancharla/javaexamples/src/9582af48772c496f004485762c45dbea690cf551/InvokeJavaScript/src/InvokeJavaScript.java?at=master
ScriptEngineManager and ScriptEngine.
ScriptEngineManager: It has 2 roles
1) Discovery of Script Engine.
2) Storing data in context. (This is shared across programs)
ScriptEngine:
This is an interface available in javax.script. Here we have to specify the scripting language.
Below is the example.
You can access source code from below link.
https://bitbucket.org/nkancharla/javaexamples/src/9582af48772c496f004485762c45dbea690cf551/InvokeJavaScript/src/InvokeJavaScript.java?at=master
No comments:
Post a Comment