I am trying to trigger a java backend process from an electron app using "child_process.spawn" . The java backend process is a .exe generated using launch4J. The application runs without any issues in dev mode but the packaged electron application keeps throwing this error when run in a different setup.
This is what the code to trigger the backend process looks like
function invokeJavaBackend() {
const javaBackendProcess = spawn(exePath, { shell: true });
javaBackendProcess.stdout.on("data", (data) => {
win && win.webContents.send("java-backend-response", data.toString());
log.info(data.toString());
});
javaBackendProcess.stderr.on("data", (data) => {
log.info(data);
setTimeout(function () {
app.exit();
}, 1000);
throw new Error("The Application could not be started");
});
javaBackendProcess.on("close", (code) => {
log.info("Java Backend child process exited with code ", code);
});
}
