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.
Update 2022: Nashorn was deprecated in Java 11, then eventually removed in Java 15.