1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> 2 <html> 3 <head> 4 <!-- 5 Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 6 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7 8 This code is free software; you can redistribute it and/or modify it 9 under the terms of the GNU General Public License version 2 only, as 10 published by the Free Software Foundation. Oracle designates this 11 particular file as subject to the "Classpath" exception as provided 12 by Oracle in the LICENSE file that accompanied this code. 13 14 This code is distributed in the hope that it will be useful, but WITHOUT 15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 version 2 for more details (a copy is included in the LICENSE file that 18 accompanied this code). 19 20 You should have received a copy of the GNU General Public License version 21 2 along with this work; if not, write to the Free Software Foundation, 22 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 24 Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 25 or visit www.oracle.com if you need additional information or have any 26 questions. 27 --> 28 29 </head> 30 <body bgcolor="white"> 31 <p>The scripting API consists of interfaces and classes that define 32 Java <font size=1><sup>TM</sup></font> Scripting Engines and provides 33 a framework for their use in Java applications. This API is intended 34 for use by application programmers who wish to execute programs 35 written in scripting languages in their Java applications. The 36 scripting language programs are usually provided by the end-users of 37 the applications. 38 </p> 39 <p>The main areas of functionality of <code>javax.script</code> 40 package include 41 </p> 42 <ol> 43 <li><p><b>Script execution</b>: Scripts 44 are streams of characters used as sources for programs executed by 45 script engines. Script execution uses 46 {@link javax.script.ScriptEngine#eval eval} methods of 47 {@link javax.script.ScriptEngine ScriptEngine} and methods of the 48 {@link javax.script.Invocable Invocable} interface. 49 </p> 50 <li><p><b>Binding</b>: This facility 51 allows Java objects to be exposed to script programs as named 52 variables. {@link javax.script.Bindings Bindings} and 53 {@link javax.script.ScriptContext ScriptContext} 54 classes are used for this purpose. 55 </p> 56 <li><p><b>Compilation</b>: This 57 functionality allows the intermediate code generated by the 58 front-end of a script engine to be stored and executed repeatedly. 59 This benefits applications that execute the same script multiple 60 times. These applications can gain efficiency since the engines' 61 front-ends only need to execute once per script rather than once per 62 script execution. Note that this functionality is optional and 63 script engines may choose not to implement it. Callers need to check 64 for availability of the {@link javax.script.Compilable Compilable} 65 interface using an <I>instanceof</I> check. 66 </p> 67 <li><p><b>Invocation</b>: This 68 functionality allows the reuse of intermediate code generated by a 69 script engine's front-end. Whereas Compilation allows entire scripts 70 represented by intermediate code to be re-executed, Invocation 71 functionality allows individual procedures/methods in the scripts to 72 be re-executed. As in the case with compilation, not all script 73 engines are required to provide this facility. Caller has to check 74 for {@link javax.script.Invocable Invocable} availability. 75 </p> 76 <li><p><b>Script engine discovery and Metadata</b>: Applications 77 written to the Scripting API might have specific requirements on 78 script engines. Some may require a specific scripting language 79 and/or version while others may require a specific implementation 80 engine and/or version. Script engines are packaged in a specified 81 way so that engines can be discovered at runtime and queried for 82 attributes. The Engine discovery mechanism is based on the Service 83 discovery mechanism described in the <b>Jar File Specification</b>. 84 Script engine implementing classes are packaged in jar files that 85 include a text resource named 86 <b>META-INF/services/javax.script.ScriptEngineFactory</b>. This 87 resource must include a line for each 88 {@link javax.script.ScriptEngineFactory ScriptEngineFactory} 89 that is packaged in the jar file. 90 {@link javax.script.ScriptEngineManager ScriptEngineManager} 91 includes 92 {@link javax.script.ScriptEngineManager#getEngineFactories getEngineFactories} method to get all 93 {@link javax.script.ScriptEngineFactory ScriptEngineFactory} instances 94 discovered using this mechanism. <code>ScriptEngineFactory</code> has 95 methods to query attributes about script engine. 96 </p> 97 </ol> 98 99 @since 1.6 100 101 </body> 102 </html>