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

前端 未结 2 459
轮回少年
轮回少年 2020-12-21 07:11

My goal is to run SVN commands from java for one of my requirements, for the same i have already installed TortoiseSVN command line tool. Added the appropriate path\"C:/Prog

相关标签:
2条回答
  • 2020-12-21 07:48

    You need to separate the executable from its arguments:

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

    See the ProcessBuilder constructor JavaDoc for more details and examples.

    0 讨论(0)
  • 2020-12-21 08:03

    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");
    
    0 讨论(0)
提交回复
热议问题