I ran into the same problem. Although classes are white, their functionality seems to be limited in App Engine. The code works fine on your local computer, but does not work when deployed to App Engine, since there are no script engines available (hence the NullPointerException).
Fortunately, you can do the same using the Rhino engine.
Note: this example is based on what was given by Harsha R at fooobar.com/questions/1382616 / ...
Download the Rhino Jar and add js.jar to your class path (you only need js-14.jar if you use Java 1.4).
String script = "function abc(x,y) {return x+y;}"; Context context = Context.enter(); try { ScriptableObject scope = context.initStandardObjects(); Scriptable that = context.newObject(scope); Function fct = context.compileFunction(scope, script, "script", 1, null); Object result = fct.call(context, scope, that, new Object[] { 2, 3 }); System.out.println(Context.jsToJava(result, int.class)); } finally { Context.exit(); } script = "3 + 2 * (4*5)"; context = Context.enter(); try{ Scriptable scope = context.initStandardObjects(); Object result = context.evaluateString(scope, script, "<cmd>", 1, null); System.out.println(result); } finally{ Context.exit(); }
source share