I've create new java project with the following code which open the command line with the project path.In the java project I've added two files(under the root) app.js and package json,now I want to invoke this node app.js
I use the following code to open the command line which is working ok
Process newProc = Runtime.getRuntime().exec("cmd /c start cmd.exe");
OutputStream out = newProc.getOutputStream();
If I put in the command line manually(which is opened by the above program): node app.js The node js is starting ok. I want to do all of this with java code something like
Runtime.getRuntime().exec("cmd /c start cmd.exe node app.js");
and either with Runtime.getRuntime().exec("node app.js");
when I try this its not working...
My Java project look like followoing
myProj
src
web
app.js
package.json
UPDATE This is the app.js file
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send("Test app running");
});
var server = app.listen(3005, function () {
console.log("listen" + 3005)
}
)