Skip to content

Instantly share code, notes, and snippets.

@frsyuki
Created October 24, 2019 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frsyuki/7e76a413c6c63ba3dd77615fa6d67e13 to your computer and use it in GitHub Desktop.
Save frsyuki/7e76a413c6c63ba3dd77615fa6d67e13 to your computer and use it in GitHub Desktop.
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
public class GraalPolyglot {
public static void main(String[] args) {
try (Context context = Context.newBuilder().allowAllAccess(true).build()) {
Value v = context.eval("ruby", "'Ruby String'");
context.getBindings("js").putMember("v", v);
context.eval("js", "print('v=' + v)"); //=> v=Ruby String
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment