Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static String evalScript(String engineName, String script) throws Exception {
        //System.out.println("evaluating "+script);
        ScriptEngineManager mgr = new ScriptEngineManager();
        ScriptEngine engine = mgr.getEngineByName("JavaScript");
        String result = "" + engine.eval(script);
        return result;
    }
}