I need for my Node application to be able to send and recieve data to/from an already running Java app or to launch Java app from Node.
So, is there a way to send data from NodeJS to Java and back?
My goal is to have something like this:
// In Java:
J2JSInterface.setReciever(msg -> System.out.println("Message from JS: " + msg));
J2JSInterface.send("Hello from Java!");
// In Java console:
// Message from JS: Hello from JS!
// In Node:
JS2JInterface.setReciever(msg => console.log(`Message from Java: ${msg}`))
JS2JInterface.send("Hello from JS!")
// In Node console:
// Message from Java: Hello from Java!
P.S.: I Tried using JNI and Node Api in one C++ library together, (code) but it won't work because Node and Java will load two independent instances of the library and these instances can't interact with each other. (or can they?)