Passing multiple arguments to java function via scriptEngine in javascript

1k views Asked by At

I am using Java script engine to run javascript at run time and I have a java method like so

public void func(Object x, Object... args)
{//CODE..}

And I am trying to call that method via the script engine

classX myClass = new classX();
scriptEngine.bind("myClass", myClass);

scriptEngine.eval("myClass.func(1, 2,3,4,5)");

But the method wont run. all I get is null, no error.

1

There are 1 answers

0
ritesh kumar poddar On

try using put instead of bind...its work for me scriptEngine.put("myClass", myClass);