I am not exactly sure what you are trying to do, but you could try something like this (since you are alluding to passing DIRECTLY from Java to Javascript) … (only applies to JDK1.6+) …
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
String javascript = "3+2*(4+5)";
System.out.println(engine.eval(javascript));
p.s. Make sure you have previously imported these..
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;
solved How to pass java variable to java script function [closed]