Java 执行javascript

/**
 * @(#) Main.java Created on 2012-11-22
 *
 * Copyright (c) 2012 Aspire. All Rights Reserved
 */
package com.braver.javascript;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * The class <code>Main</code>
 * 
 * @author ouyangfeng
 * @version 1.0
 */
public class Main {

    /**
     * @param args
     * @throws ScriptException 
     */
    public static void main(String[] args) throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("javascript");
        engine.eval("println('111');");
    }

//    public String readScript() {
//
//    }

}
 

你可能感兴趣的:(JavaScript)