Runtime.getRuntime().exec(“node.exe D:\java\node\server.js”);
js var http=require(‘http’); http.createServer(function(req,res){ res.writeHead(200,{‘Content-Type’:‘text/plain’}); res.end(‘hello\n’); }).listen(8888,‘127.0.0.1’); console.log(‘Server running at http://127.0.0.1:8124/’);
报错 node.exe D:\java\node\server.js java.io.IOException: Cannot run program “node”: CreateProcess error=2, ϵͳÕҲ»µ½ָ¶ at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at com.node.NodeTest.test(NodeTest.java:21) at com.node.NodeTest.main(NodeTest.java:8) Caused by: java.io.IOException: CreateProcess error=2, ϵͳÕҲ»µ½ָ¶ at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) … 6 more
请大神指点哈
还有怎么在bat 里执行 server.js
请大神指点哈 谢谢鸟
备注, 乱码 控制台打印的就是乱码 node.exe D:\java\node\server.js 改为node D:\java\node\server.js 也一样 在控制台里 node.exe D:\java\node\server.js 是可以启动服务的