Last active
August 30, 2021 09:27
-
-
Save vmi/18395fae0e01d338c04d332e51f50026 to your computer and use it in GitHub Desktop.
Script Engine Test
This file contains hidden or 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
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
import javax.script.ScriptException; | |
public class Main { | |
public static void main(String[] args) throws ScriptException { | |
ScriptEngineManager manager = new ScriptEngineManager(); | |
ScriptEngine engine = manager.getEngineByName("js"); | |
System.out.println(engine.toString()); | |
Object result = engine.eval("1 + 2"); | |
System.out.println("Result: " + result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Java11
GraalJS 21.2.0
Java17(Preview)