Rhino is what you are looking for.
Rhino is an open-source implementation of JavaScript written entirely
in Java. It is typically embedded into Java applications to provide
scripting to end users.
Update:
Now Nashorn, which is more performant JavaScript Engine for Java, is available with jdk8.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…