Skip to content

Instantly share code, notes, and snippets.

@ialex32x
Created July 6, 2017 06:31
Show Gist options
  • Save ialex32x/a609b5eb130c67ae67958ba373809827 to your computer and use it in GitHub Desktop.
Save ialex32x/a609b5eb130c67ae67958ba373809827 to your computer and use it in GitHub Desktop.
Nashorn Basis
# eval
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval("print('hello')");
# javascript
function Person(name) {
this.name = name;
this.getName = function () {
return this.name
}
}
# MyJavaClass.java
static void foo(ScriptObjectMirror person) {
System.out.println(person.callMember("getname"));
}
# javascript
MyJavaClass.foo(new Person("Peter"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment