Hello!
I am running Node.js on my backend, but I also need to run a Java command. I am unable to install both Node.js and Java, which is where this module comes in. When I attempt to wait for the results, including the success exit code, the exit code is null, and I am unable to proceed to the next step.
I need to run the a11yPDFGenerator on an HTML file that is passed to my backend. Once a11yPDFGenerator is complete, it creates a PDF file in the location I have passed, which does work using const result = await runner.runJar('pdf/a11yPDFGenerator-1.0.0.jar', [${tmpFilePath}.html, ${tmpFilePath}.pdf]), but when I attempt to check for the success exit code from my result, it comes back as null.
How can I properly wait for the Java command to complete so I can proceed to the next step in my process?
Code for reference:
const runner = create({
debug: true,
jreMajor: 17,
workdir: 'pdf/runtime'
});
const filename = `report_${date}`;
const tmpFilePath = `pdf/tmp/${filename}`;
await writeFile(`${tmpFilePath}.html`, req.body.html);
await runner.init({
workdir: 'pdf/runtime',
minimumVersion: 17
});
console.log('🚀 Starting JAR with basic listener...\n');
// Run JAR with listener for real-time logging
const result = await runner.runJar('pdf/a11yPDFGenerator-1.0.0.jar', [`${tmpFilePath}.html`, `${tmpFilePath}.pdf`], {
onStdout: (data) => {
console.log(`📤 STDOUT: ${data.trim()}`);
},
onStderr: (data) => {
console.log(`⚠️ STDERR: ${data.trim()}`);
}
});
console.log(`\n✅ Execution completed - Exit code: ${result.exitCode}`); // exitCode is null
if (result.exitCode === 0) {
// How do I get this to run?
console.log('exit code is 0');
}
Here is the output:
[NodeJavaRunner] Using cached JRE at pdf/runtime/jre-17-mac-aarch64
🚀 Starting JAR with basic listener...
[NodeJavaRunner] Running JAR: pdf/a11yPDFGenerator-1.0.0.jar with Java: pdf/runtime/jre-17-mac-aarch64/jdk-17.0.19+10-jre/Contents/Home/bin/java
✅ Execution completed - Exit code: null
📤 STDOUT & ⚠️ STDERR // normal output from a11yPDFGenerator
📤 STDOUT: ✅ Generated accessible PDF: pdf/tmp/report_1782761978851.pdf // normal output from a11yPDFGenerator
Hello!
I am running Node.js on my backend, but I also need to run a Java command. I am unable to install both Node.js and Java, which is where this module comes in. When I attempt to wait for the results, including the success exit code, the exit code is null, and I am unable to proceed to the next step.
I need to run the a11yPDFGenerator on an HTML file that is passed to my backend. Once a11yPDFGenerator is complete, it creates a PDF file in the location I have passed, which does work using
const result = await runner.runJar('pdf/a11yPDFGenerator-1.0.0.jar', [${tmpFilePath}.html,${tmpFilePath}.pdf]), but when I attempt to check for the success exit code from my result, it comes back as null.How can I properly wait for the Java command to complete so I can proceed to the next step in my process?
Code for reference:
Here is the output: