如何在 java 中调用 node.js 并将 console.log 值保存在 String 变量中?
How can I call a node.js inside java and save the console.log values in a String variable?
Java 应用程序可以与正在运行的 Node.JS 应用程序进行通信.例如,您可以让 Node.JS 应用程序在可用端口上运行,而 Java 应用程序可以通过 tcp 套接字与其通信.
It is possible for a Java application to communicate with a running Node.JS application. For instance, you can have a Node.JS app running on an available port and the Java app can communicate with it via tcp sockets.
http://nodejs.org/api/net.html
或者您可以创建一个 http 服务器并公开一个您的 Java 应用可以使用的 rest 服务.
Or you can create an http server and expose a rest service which your Java app can consume.
http://nodejs.org/api/http.html
或者如 md_5 所说,您可以使用 Runtime.exec,然后在结果进程上调用 getInputStream.
Or as md_5 says, you can use Runtime.exec and then call getInputStream on the resulting process.
http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html
node.js 和 Java 之间的通信方式与其他可以完成的跨应用程序通信没有什么不同.
The ways you can communicate between node.js and Java are no different from other cross application communication that can be done.
还可以使用 node-java 之类的东西从 Node.JS 应用程序调用 Java 代码.
It is also possible to invoke Java code from your Node.JS application using something like node-java.
https://github.com/nearinfinity/node-java
这篇关于从 java 内部调用 node.js 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
上传进度侦听器未触发(Google 驱动器 API)Upload progress listener not fired (Google drive API)(上传进度侦听器未触发(Google 驱动器 API))
使用 Google Drive SDK 将文件保存在特定文件夹中Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 将文件保存在特定文件夹中)
Google Drive Android API - 无效的 DriveId 和 Null ResourcGoogle Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 无效的 DriveId 和 Null ResourceId)
谷歌驱动api服务账户查看上传文件到谷歌驱动使Google drive api services account view uploaded files to google drive using java(谷歌驱动api服务账户查看上传文件到谷歌驱动使用java
Google Drive 服务帐号返回 403 usageLimitsGoogle Drive service account returns 403 usageLimits(Google Drive 服务帐号返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory;Google Drcom.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例