2017-04-03 80 views
0

我需要的是接受一個路徑(通過args)到mongod.cfg文件並使用它從java啓動mongod。這是whar我使用如何在Windows中使用cmd啓動程序

Runtime.getRuntime().exec("cmd /k start mongod --config C:\\Users\\Ivan\\git\\StudentsDBMS_Server\\StudentsDBMS_Server\\mongod.bat"); 

而這就是我得到 enter image description here

下拆除它不運行命令開始命令。 你也可以解釋爲什麼它無限打印命令,但不執行其中的任何一個。

+1

看起來你有一個調用'mongod'的'mongod'批處理文件,也就是說它會一遍又一遍地調用它自己。 –

回答

0

謝謝MC ND和RⅣ, 我用最後的命令是

Runtime.getRuntime().exec("cmd /k start mongod --config \"C:\\Users\\Ivan\\git\\StudentsDBMS_Server\\StudentsDBMS_Server\\mongod.cfg\""); 

和我改名mongod.batmongoServer.bat

0

也許cmd語法關閉。嘗試像這樣也許:

'cmd /k "start mongod --config C:\\Users\\Ivan\\git\\StudentsDBMS_Server\\StudentsDBMS_Server\\mongod.bat"' 
+0

它給出了確切的輸出作爲截圖。 – pebble

相關問題