How do I get the supported scripting engine?

package org.kodejava.example.script;

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

public class GetSupportedScriptingEngine {
    public static void main(String[] args) {
        // Creating an instance of ScriptEngineManager an get the list
        // of available ScriptEngineFactory.
        ScriptEngineManager manager = new ScriptEngineManager();
        List<ScriptEngineFactory> factories = manager.getEngineFactories();

        for (ScriptEngineFactory factory : factories) {
                    "EngineName      = " + factory.getEngineName());
                    "EngineVersion   = " + factory.getEngineVersion());
                    "LanguageName    = " + factory.getLanguageName());
                    "LanguageVersion = " + factory.getLanguageVersion());
                    "Extensions      = " + factory.getExtensions());

            List<String> names = factory.getNames();
            for (String name : names) {
                System.out.println("Engine Alias = " + name);

The code above produces the following information.

EngineName      = Mozilla Rhino
EngineVersion   = 1.7 release 3 PRERELEASE
LanguageName    = ECMAScript
LanguageVersion = 1.8
Extensions      = [js]
Engine Alias = js
Engine Alias = rhino
Engine Alias = JavaScript
Engine Alias = javascript
Engine Alias = ECMAScript
Engine Alias = ecmascript

Currently, as you can see in the result of the program above, Mozilla Rhino is the only scripting engine provided in the JDK 6 libraries. You can also see that the factory provides many engine name aliases that help you to obtain an engine for the JavaScript programming language.

Wayan Saryada

Founder at Kode Java Org
I am a programmer, a runner, a recreational diver, currently live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. You can support my works by donating here. Thank you 🥳

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.