Can we bridge between NodeJS and Maven Java application?

I have a maven based standalone Spark application. Let's assume that the main class of the application is "HelloWorldnAddition.java". I can easily start my main class by throwing the command exec:java -Dexec.mainClass=HelloWorldnAddition

.

I understand npm java and know how a simple Java class can connect to NodeJS and we can easily call the methods of the java class in the NodeJS * .js page like

! / usr / bin / env node

var java = require("../");
java.classpath.push("./src");
var MyClass = java.import("com.nearinfinity.nodeJava.MyClass");
var result = MyClass.addNumbersSync(1, 4);
console.log(result);

      

I need the exact thing with a maven project that I can easily call the maven class in my NodeJS * .js page and call its method as described above. Is there any way to do this. I have tried several maven packages in npm but it seems to be useless.

+3


source to share





All Articles