Tuesday, May 6, 2014

List available ScriptEngine

The following program list ScriptEngine(s) available in your system.
package javalistscript;

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

/**
 *
 * @web java-buddy.blogspot.com
 */
public class JavaListScript {

    public static void main(String[] args) {
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        List<ScriptEngineFactory> listScriptEngineFactory =
                scriptEngineManager.getEngineFactories();
        for(ScriptEngineFactory factory : listScriptEngineFactory){
            System.out.println("ScriptEngine: " + factory.getScriptEngine());
            System.out.println("EngineName: " + factory.getEngineName());
            System.out.println("EngineVersion: " + factory.getEngineVersion());
            System.out.println("LanguageName: " + factory.getLanguageName());
            System.out.println("LanguageVersion: " + factory.getLanguageVersion());
            
            List<String> listExtensions = factory.getExtensions();
            for(String ext : listExtensions){
                System.out.println("Extension: " + ext);
            }
            
            List<String> listMimeTypes = factory.getMimeTypes();
            for(String mimeType : listMimeTypes){
                System.out.println("MimeType: " + mimeType);
            }
        }
    }
    
}



No comments:

Post a Comment