2021年4月5日星期一

java jar no show if is running when execute in nodeJs?

In advance forgive me for my poor English.

I am trying to run java jar file in nodeJs, and that looks like it's running but it does not show anything until I again save the project(since I am using nodemon reload on save)

The image to below, show what I want to say.

enter image description here

how to we can see, when is running no show any information(red color), but on save(reload by nodemon) i show that is runnig and then error(blue color)

My question is ¿ how can I see the jar is running in nodejs?

MY CODE

const { exec } = require('child_process');    const executeJavaApp = () => {    let path = `${__dirname}`;    path = path.replace(/\\/g, "/") + '/javaApp/DADKafkaConsumer-1.0.1-SNAPSHOT.jar';    path = path.replace(/\/utils/, '');      exec(`java -jar ${path}`, (error, stdout, stderr) => {      console.log(stdout);      if (error) {        console.error(`exec error: ${error}`);        return;      }      console.log(`stdout: ${stdout}`);      console.error(`stderr: ${stderr}`);    });  }  

INFORMATION

  • WINDOWS 10
  • NODEJS 12.19.0
https://stackoverflow.com/questions/66961473/java-jar-no-show-if-is-running-when-execute-in-nodejs April 06, 2021 at 08:58AM

没有评论:

发表评论