Can I call Java from Node.js via JNI and how?

后端 未结 5 2011
难免孤独
难免孤独 2020-12-02 08:20

can I call Java from Node.js via JNI? Are there any examples?

5条回答
  •  [愿得一人]
    2020-12-02 08:26

    That looks tricky. Node.JS runs on the Google Chrome JavaScript engine V8. What you will have to do is to create a V8 C++ binding (v8 c++ Crash Course shows an example) that starts a JVM and does all the JNI handling.

    I think you might be better off letting a JavaServer and Node.js communicate via the network (someone wrote an example for using RabbitMQ for Java/Node.js message based communication). Here, JSON would be a great data exchange format (if you trust your Java server produces proper JSON you can just eval() it in Node).

提交回复
热议问题