0N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2362N/ACopyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 0N/ADO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/AThis code is free software; you can redistribute it and/or modify it 0N/Aunder the terms of the GNU General Public License version 2 only, as 2362N/Apublished by the Free Software Foundation. Oracle designates this 0N/Aparticular file as subject to the "Classpath" exception as provided 2362N/Aby Oracle in the LICENSE file that accompanied this code. 0N/AThis code is distributed in the hope that it will be useful, but WITHOUT 0N/AANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/AFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/Aversion 2 for more details (a copy is included in the LICENSE file that 0N/Aaccompanied this code). 0N/AYou should have received a copy of the GNU General Public License version 0N/A2 along with this work; if not, write to the Free Software Foundation, 0N/AInc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2365N/APlease contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A<
body bgcolor="white">
0N/A<
p>The scripting API consists of interfaces and classes that define
0N/AJava <
font size=1><
sup>TM</
sup></
font> Scripting Engines and provides
0N/Aa framework for their use in Java applications. This API is intended
0N/Afor use by application programmers who wish to execute programs
0N/Awritten in scripting languages in their Java applications. The
0N/Ascripting language programs are usually provided by the end-users of
0N/A <
li><
p><
b>Script execution</
b>: Scripts
0N/A are streams of characters used as sources for programs executed by
0N/A script engines. Script execution uses
0N/A <
li><
p><
b>Binding</
b>: This facility
0N/A allows Java objects to be exposed to script programs as named
0N/A classes are used for this purpose.
0N/A <
li><
p><
b>Compilation</
b>: This
0N/A functionality allows the intermediate code generated by the
0N/A front-end of a script engine to be stored and executed repeatedly.
0N/A This benefits applications that execute the same script multiple
0N/A times. These applications can gain efficiency since the engines'
0N/A front-ends only need to execute once per script rather than once per
0N/A script execution. Note that this functionality is optional and
0N/A script engines may choose not to implement it. Callers need to check
0N/A interface using an <
I>instanceof</
I> check.
0N/A <
li><
p><
b>Invocation</
b>: This
0N/A functionality allows the reuse of intermediate code generated by a
0N/A script engine's front-end. Whereas Compilation allows entire scripts
0N/A represented by intermediate code to be re-executed, Invocation
0N/A be re-executed. As in the case with compilation, not all script
0N/A engines are required to provide this facility. Caller has to check
0N/A <
li><
p><
b>Script engine discovery and Metadata</
b>: Applications
0N/A written to the Scripting API might have specific requirements on
0N/A script engines. Some may require a specific scripting language
0N/A and/
or version while others may require a specific implementation
0N/A engine
and/
or version. Script engines are packaged in a specified
0N/A way so that engines can be discovered at runtime and queried for
0N/A attributes. The Engine discovery mechanism is based on the Service
0N/A discovery mechanism described in the <
b>Jar File Specification</
b>.
0N/A Script engine implementing classes are packaged in jar files that
0N/A include a text resource named
0N/A resource must include a line for each
0N/A that is packaged in the jar file.
0N/A discovered using this mechanism. <
code>ScriptEngineFactory</
code> has
0N/A methods to query attributes about script engine.