public class Script {
public static void main(String[] args) {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
Rect rect = new Rect();
engine.put("rectangle",rect);
try {
engine.eval("rectangle.setAttribute('x',32);");
System.out.println(rect.getAttribute("x"));
} catch (ScriptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}