Skip to content

Instantly share code, notes, and snippets.

@dulichan
Created January 12, 2014 16:29
Show Gist options
  • Save dulichan/8386898 to your computer and use it in GitHub Desktop.
Save dulichan/8386898 to your computer and use it in GitHub Desktop.
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class RhinoEngine {
public static void main(String[] args) {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
try {
engine.put("name", args[0]);
engine.eval("print('Hello ' + name + '!')");
} catch (ScriptException ex) {
ex.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment