Running msys.bat using ProcessBuilder

前端 未结 1 1411
故里飘歌
故里飘歌 2021-02-10 20:41

I am attempting to run msys.bat in java using ProcessBuilder. When I run the .bat file with my program, the following error occurred: \"Cannot find the rxvt.exe or sh.exe binary

1条回答
  •  清酒与你
    2021-02-10 21:21

    .bat files can't run on their own and are called on the Windows command processor. So don't forget to load the Windows command processor too, cmd.exe before your bat file.

    ProcessBuilder Msys = new ProcessBuilder("cmd.exe", "C:/msys/1.0/msys.bat", 
           "/C", "find \"C:/Users/Dan G/Desktop/hello.elf\"");
    

    Edit
    Please check out this useful article for tips and traps that occur with this process: when runtime.exec() won't. The code in the article is a bit dated, but the concepts are just as germane today as they were then. It is highly recommended.

    0 讨论(0)
提交回复
热议问题