Embed JavaScript in Java.
import javax.script.*;
public class EvalScript {
public static void main(String[] args) throws Exception {
// create a script engine manager
ScriptEngineManager factory = new ScriptEngineManager();
// create a JavaScript engine
ScriptEngine engine = factory.getEngineByName("JavaScript");
// evaluate JavaScript code from String
engine.eval("print('Hello, World')");
}
}
'Programming' 카테고리의 다른 글
(Java, JavaScript) Problems using Rhino on Android (0) | 2013.03.15 |
---|---|
(Windows) How to read input from console in a batch file? (0) | 2013.03.14 |
(Clojure) Creating an empty string array (0) | 2013.03.06 |
(Java) Lesson: Using Swing Components (0) | 2013.03.05 |
(Java) java.lang.reflect.Constructor.newInstance : 자바 클래스 인스턴스를 동적으로 생성하기 (0) | 2013.03.04 |