J2V8 ReferenceError : process is not defined, when trying to execute script

413 Views Asked by At

I'm using J2V8 to call a javascript function from my Java code. When I try to execute my script it gives me ReferenceError : process is not defined. The script uses reactDomServer to transform a hash map into an html object.

I'm initializing my V8 as follows:

V8 v8 = v8.createV8Runtime("global");

Also, is there a way to pass a hashmap as parameter when you want to call a JS function using V8?

v8.executeJsScript("myFunction", myHashMap) 

This was working with nashorn but im not able to make it work with V8. It seems my parameters need to be V8 values or primitives. All the examples I find are very simple and pass only strings or integers as parameters.. If my parameters are a few objects, should I declare them as V8 values and then push them in a V8 array and pass that array as my function parameters?

Thanks!

1

There are 1 best solutions below

0
On

You can use V8ObjectUtils.toV8Object to create a V8Object from a HashMap.