Java ScriptEngineFactory Example

This example shows how to get the details of the script engines supported by your JVM. Java supports the different script engines that can be retrieved and used depends upon the client side scripts. Java provides javax.script.ScriptEngineFactory for storing all the script engine details like script engine name, version, default script engine, language, etc. You can use getEngineFactories() method in the javax.script.ScriptEngineManager to get the list of factories and the associated script engines. Lets look at the example.


import java.util.List;

import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;

 * Java ScriptEngineFactory Details Example
 * @author Krishna
public class ScriptEngineFactoryExample {
	public static void main(String[] args){

		// Create ScriptEngineManager
		ScriptEngineManager engineManager = new ScriptEngineManager();

		//Get the ScriptEngineFactory List
		List list = engineManager.getEngineFactories();

		//Print the supported ScriptEngine Names

		//Print the supported ScriptEngine MimeTypes

		//Print the default script engine


[application/javascript, application/ecmascript, text/javascript, text/ecmascript]
Mozilla Rhino



About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.