Error: Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified. Applies for all executables

谁说胖子不能爱 提交于 2019-11-29 15:02:08

It's because you're not using ProcessBuilder correctly. The Javadocs are pretty clear cut.

You can't pass the --version argument as part of the process name you're trying to invoke; that's not the filename of the process. Behind the scenes you're exec'ing a process directly - there's no shell involved.

ProcessBuilder svnProcessBuilder = new ProcessBuilder("svn", "--version");

You need to separate the executable from its arguments:

new ProcessBuilder("svn", "--version")

See the ProcessBuilder constructor JavaDoc for more details and examples.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!