Skip to content

Java, showing script engines

A simple code to show the script engines installed in your system.

As it uses the JSR-223 you need at least java 6.

import javax.script.ScriptEngineManager;
import javax.script.ScriptEngineFactory;
import java.util.List;

public class ListEngines {
    public static void main(String[] args){
	ScriptEngineManager manager = new ScriptEngineManager();
	List  engines = manager.getEngineFactories();
	for(ScriptEngineFactory engine: engines){
		String name = engine.getEngineName();
		String lang = engine.getLanguageName();
		String ver = engine.getLanguageVersion();
		System.out.println(name+" "+lang+" "+ver);
	}
    }
}

$ java -version
java version “1.6.0_0”
OpenJDK Runtime Environment (build 1.6.0_0-b11)
OpenJDK Client VM (build 1.6.0_0-b11, mixed mode, sharing)
$ javac ListEngines.java
$ java ListEngines
Mozilla Rhino ECMAScript 1.6

For now I just have Rhino ECMAScript (JavaScript) engine accessible that comes with Java 6. I’m trying now to call Jython and JRuby code.

Published inenglish

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *