Runtime.getRuntime().exec(commandToBeExecuted);
and commandToBeExecuted ="git log" ;
我已经设置ENV变量运行通过java程序一个git命令,但仍然得到错误,如:
java.io.IOException: Cannot run program "git": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at GITCodeCoverage.createLog(GITCodeCoverage.java:40)
at GITCodeCoverage.main(GITCodeCoverage.java:17)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:188)
at java.lang.ProcessImpl.start(ProcessImpl.java:132)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 5 more
任何这个命令可以帮助我在Windows系统上成功运行这个命令。
在此先感谢!
只要你知道,没有安装我的Ubuntu机器使用Git上会出现此错误。 –
这个错误不会发生在我的Windows机器上。当你在cmd中手动输入时,做这个命令的工作是什么? –
是的,当我从命令Promt运行此命令它工作正常,并给出结果。我是否需要在日食中设置任何路径。 –