I had a node js application and I want to execute a very basic jar file which has System.out.println("Hello");
So that I need to capture that result in one variable.How can we do this.
I tried this
var exec = require('child_process').exec;
var child = exec('java -jar ./TestFile.jar',
function (error, stdout, stderr){
console.log('Output -> ' + stdout);
if(error !== null){
console.log("Error -> "+error);
}
});
module.exports = child;
But it is giving me error as
Output ->
Error -> Error: Command failed: C:\windows\system32\cmd.exe /s /c "java -jar ./TestFile.jar"
no main manifest attribute, in ./TestFile.jar
Can someone help how can we run this jar file so that I can display that result on my client side.
I had a node js application and I want to execute a very basic jar file which has System.out.println("Hello");
So that I need to capture that result in one variable.How can we do this.
I tried this
var exec = require('child_process').exec;
var child = exec('java -jar ./TestFile.jar',
function (error, stdout, stderr){
console.log('Output -> ' + stdout);
if(error !== null){
console.log("Error -> "+error);
}
});
module.exports = child;
But it is giving me error as
Output ->
Error -> Error: Command failed: C:\windows\system32\cmd.exe /s /c "java -jar ./TestFile.jar"
no main manifest attribute, in ./TestFile.jar
Can someone help how can we run this jar file so that I can display that result on my client side.
Share Improve this question edited Oct 15, 2018 at 17:03 Cœur 38.8k25 gold badges205 silver badges277 bronze badges asked Mar 15, 2017 at 13:36 user7350714user7350714 3652 gold badges6 silver badges23 bronze badges 1-
That looks like an issue with the JAR manifest rather than your Node code. Have you tried running
java -jar ./TestFile.jar
manually? – Joe Clay Commented Mar 15, 2017 at 13:37
1 Answer
Reset to default 4You obviously haven't specified a Main-Class
in your jar's manifest so you can't run it via java -jar
. See here for more info.
If not using a Main-Class
entry in your jar's manifest, you'll need to run via
java -cp ./TestFile.jar .foo.MyMainClass