java中实现javascript eval()功能

import bsh.EvalError;
import bsh.Interpreter;

public class BeahshellTest1 {
   
   
public static void main(String[] args) throws EvalError {
        Interpreter bsh
= new Interpreter();
        bsh.eval(
" int a = 5, b = a + 6; " ); "b"));

        System.out.println(bsh.get("b"));

    }
}

 

 

Beanshell
http://www.beanshell.org

你可能感兴趣的:(java中实现javascript eval()功能)