Below is my code.
I am not sure why am I getting the error
"javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "lcc" is not defined......."
import java.io.BufferedReader;
import java.io.InputStreamReader;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Eval {
public static void main (String[] args) throws Exception {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
System.out.println("Please enter the two numbers separated by commas and press Enter");
BufferedReader consoleinput = new BufferedReader(new InputStreamReader(System.in));
String input = consoleinput.readLine();
String[] lc = input.split(",");
int lclen = lc.length;
for (int i=0;i<lclen;i++)
{
String xx = "lcc["+i+"]";
engine.put(xx, lc[i]);
}
try
{
String script = "lcc[0]>lcc[1]";
Object bol = engine.eval(script);
System.out.println(bol);
}
catch (ScriptException e)
{
e.printStackTrace();
}
}
}