我可以通过JNI从Node.js调用Java吗?如何? [英] Can I call Java from Node.js via JNI and how?

查看:93
本文介绍了我可以通过JNI从Node.js调用Java吗?如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过 JNI 从Node.js调用Java吗?有没有例子?

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

推荐答案

这看起来很棘手。 Node.JS在Google Chrome JavaScript引擎 V8 上运行。您需要做的是创建一个V8 C ++绑定( v8 c ++速成课程展示了一个启动JVM并执行所有JNI处理的示例。

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.

我认为您可能最好让JavaServer和Node.js通过网络进行通信(某人)写了使用RabbitMQ进行基于Java / Node.js消息的通信的示例)。在这里,JSON将是一种出色的数据交换格式(如果您信任您的Java服务器生成正确的JSON,您可以在Node中eval())。

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).

这篇关于我可以通过JNI从Node.js调用Java吗?如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆