Created
July 25, 2008 12:07
-
-
Save jmesnil/2425 to your computer and use it in GitHub Desktop.
How to execute JavaScript code from a Java class
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
public class JavaScriptTest { | |
public static void main(String[] args) throws Exception { | |
ScriptEngineManager factory = new ScriptEngineManager(); | |
ScriptEngine engine = factory.getEngineByName("JavaScript"); | |
engine.eval("print('hello, world!')"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment