The Java Scripting API, introduced in Java SE 6, provides support that allows Java applications and scripting languages to interact through a standard interface. This API is detailed in JSR 223, “Scripting for the Java Platform,” and is contained in the
javax.script package found within the
ScriptEngine interface provides the fundamental methods for the API. The
ScriptEngineManager class works in conjunction with this interface and provides a means to establish the desired scripting engines to be utilized.
The scripting API includes the ability to embed scripts and/or scripting components into Java applications.
The following example shows two ways to embed scripting components into a Java application: (1) the scripting engine’s
eval method reads in the scripting language syntax directly, and (2) the scripting engine’s
eval method reads the syntax in from a file: