Created
July 6, 2017 06:31
-
-
Save ialex32x/a609b5eb130c67ae67958ba373809827 to your computer and use it in GitHub Desktop.
Nashorn Basis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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