avhimkov
8/5/2016 - 8:58 AM

How To Get Java ScriptEngine By MimeType

How To Get Java ScriptEngine By MimeType

ScriptEngine Loaded using MimeTypes!!
Welcome To JavaBeat!!!
package javabeat.net.script;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * Get ScriptEngine By MimeType Example.
 *
 * @author Krishna
 *
 */
public class GetScriptEngineExample {
	public static void main(String[] args) throws ScriptException{

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

		//Get script engine using name
		ScriptEngine engine = engineManager.getEngineByMimeType("application/javascript");

		//Evaluate simple printing message
		engine.eval("println('ScriptEngine Loaded using MimeTypes!!')");
		engine.eval("print('Welcome To JavaBeat!!!')");

	}
}