SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

SCRIPTING / NOTES</>↗
Scripting28 Jul 2009

How do I access Java object from a script?

This example demonstrate how you can access Java object from a script. We start by creating the ScriptEngine object. Then we obtain the Bindings object from the engine and set the polyglot.js.allowHostAccess options to true. We do this using the Bindings‘s put(String name, Object value) method. After that we can put Java object into the […]

Wayan · 3 min read
SCRIPTING / NOTES</>↗
Scripting28 Jul 2009

How do I get a ScriptEngine by language name and version?

This example show you how you can obtain a script engine for a specific language name and specific language version. In the code below we try to obtain script engine instance for ECMAScript version ECMAScript 262 Edition 11. package org.kodejava.script; import javax.script.ScriptEngineManager; import javax.script.ScriptEngineFactory; import javax.script.ScriptEngine; import javax.script.ScriptException; import java.util.List; public class ScriptEngineSearch { public […]

Wayan · 2 min read
SCRIPTING / NOTES</>↗
Scripting23 Jul 2009

How do I call a specific function of a script?

This code demonstrate the use of Invocable interface to invoke a specific function of a script. The Invocable.invokeFunction() takes the function name with or without a parameter as the function’s parameter. The parameter value can be passed as a varargs. package org.kodejava.script; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; import javax.script.Invocable; public class InvokingFunction { public […]

Wayan · 2 min read
SCRIPTING / NOTES</>↗
Scripting20 Jul 2009

How do I evaluate or execute a script file?

This example demonstrated how to evaluate script that stored on a file. As we know that the eval() method can also accept a Reader object we can then read the script file using FileReader and pass it as the parameter to the eval() method of the ScriptEngine for further evaluation. package org.kodejava.script; import javax.script.ScriptEngineManager; import […]

Wayan · 2 min read
SCRIPTING / NOTES</>↗
Scripting20 Jul 2009

How do I get the supported scripting engine?

package org.kodejava.script; import javax.script.ScriptEngineManager; import javax.script.ScriptEngineFactory; import java.util.List; public class GetSupportedScriptingEngine { public static void main(String[] args) { // Creating an instance of ScriptEngineManager an get the list // of available ScriptEngineFactory. ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : fa...

Wayan · 2 min read
SCRIPTING / NOTES</>↗
Scripting19 Jul 2009

How do I get ScriptEngine by engine name?

This example shows how to get an instance of ScriptEngine by the engine name. Below we are trying to obtain the GraalVM JavaScript engine. package org.kodejava.script; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; public class GettingScriptEngineByName { public static void main(String[] args) { ScriptEngineManager manager = new ScriptEngineManager(); // Obtain an instance of ScriptEngine using the […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.