I have a math class in a package mypackage
.
Now I want to import this class in MVEL and assign values to its property and access its method.
I have written the following code but its giving error as
Exception in thread "main" [Error: unknown class or illegal statement:
^
Code is
ParserContext context = new ParserContext();
context.addImport("math",mypackage.MyMaths.class);//MyMaths.class is public
context.addInput("obj", mypackage.MyMaths.class);
String expression1 = "obj.a == 20";//a is public property
Serializable compiled1 = MVEL.compileExpression(expression1,context);
MVEL.executeExpression(compiled1);