Try Beanshell
http://www.beanshell.org/intro.html
Java evaluation features:
Compute the complete Java source classes dynamically, as well as isolated Java methods, instructions, and expressions.
Feature Summary
Dynamic execution of the full Java syntax, fragments of Java code, as well as weakly typed Java and additional scripting capabilities.
Transparent access to all Java objects and APIs.
It works in four modes: Command Line, Console, Applet, Remote Session Server. It can work in an environment with security restrictions without generating a class or bytecode for most functions.
Interpreter is a small file with a size of 150K.
Pure Java.
It's free!!
There is another option in the link below that you could try
Java syntax checking
source share