Mega Code Archive

 
Categories / Java Tutorial / Development
 

Retrieving Script Engines by Name

A script engine registers alias names with the scripting framework. For example, the built-in Rhino scripting registers the following names with the scripting framework: js rhino JavaScript javascript ECMAScript ecmascript import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; public class GetEngineByName {   public static void main(String[] args) {     ScriptEngineManager manager = new ScriptEngineManager();     /* Retrieve a ScriptEngine registered with the rhino name */     ScriptEngine jsEngine = manager.getEngineByName("rhino");     if (!(jsEngine == null)) {       System.out.println(jsEngine);     } else {       System.out.println("\nNo supported script engine foundregistered as Rhino.");     }   } }