Home » Core Java » script

script

Get script engine by name

With this example we are going to demonstrate how to get the ScriptEngine by name. The ScriptEngine interface is the fundamental interface whose methods must be fully functional in every implementation of this specification. These methods provide basic scripting functionality. Applications written to this simple interface are expected to work with minimal modifications in every implementation. It includes methods that ...

Read More »

Get script engine’s details

In this example we shall show you how to get the ScriptEngine‘s details. The ScriptEngine interface provides methods for basic scripting functionality. Applications written to this simple interface are expected to work with minimal modifications in every implementation. It includes methods that execute scripts, and ones that set and get values. To get the ScriptEngine’s details one should perform the ...

Read More »

Evaluate a simple script

This is an example of how to evaluate a simple script in Java. We are using the ScriptEngine interface, that provides methods for basic scripting functionality. Applications written to this simple interface are expected to work with minimal modifications in every implementation. It includes methods that execute scripts, and ones that set and get values. Evaluating a script implies that you ...

Read More »

Modify Java object in script

With this example we are going to demonstrate how to modify a Java object in script. In short, to modify a Java object using script we have followed the steps below: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains a collection of key/value pairs storing state shared by all engines created ...

Read More »

Import package in script

In this example we shall show you how to import a package in script. We are using the ScriptEngine interface, that provides methods for basic scripting functionality. To import a package in script one should perform the following steps: Create a StringBuilder to build the script. Append to it all the commands to be executed, along with the import package command. Get ...

Read More »

Evaluate a script file

With this example we are going to demonstrate how to evaluate a simple script file in Java. We are using the ScriptEngine interface that provides methods for the basic scripting functionality. In short, to evaluate a script file you should: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains a collection ...

Read More »

Invoke specific script function

This is an example of how to invoke a specific script function. We are using the ScriptEngine interface that provides methods for the basic scripting functionality. Invoking a script function with Java implies that you should: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains a collection of key/value pairs storing state ...

Read More »

Access Java Object from a script

In this example we shall show you how to access a Java Object from a script. We are using the ScriptEngine interface that provides methods for the basic scripting functionality. To access a Java Object from a script one should perform the following steps: Create a new ScriptEngineManager. The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains ...

Read More »