Java调用Node,可以使用库j2v8
<dependency>
<groupId>com.eclipsesource.j2v8</groupId>
<artifactId>j2v8_linux_x86_64</artifactId>
<version>4.8.0</version>
</dependency>
package bj;
import com.eclipsesource.v8.NodeJS;
class App {
public static void main(String[] var0) {
System.out.println(NodeJS.createNodeJS().getRuntime().executeStringScript("new Date().toString()"));
}
}
Thu Sep 20 2018 21:12:03 GMT+0800 (CST)