Problem with Runtime.getRuntime().exec when running java in .bat

Discussion in 'Java' started by Shayko, Nov 9, 2009.

  1. Shayko

    Shayko New Member

    Nov 9, 2009
    Likes Received:
    Trophy Points:
    in my code i'm using Runtime.getRuntime().exec() in order to run a .bat file that calls another java program (they communicate with each other using RMI).
    when i call:
    Process process = Runtime.getRuntime().exec("cmd /c start C:\\MyFolder\\JavaApp.bat");
    the seperate process runs perfectly, but when i add a space to the path:
    Process process = Runtime.getRuntime().exec("cmd /c start \"C:\\My Folder\\JavaApp.bat\"");
    then the java.exe refuses to load and all i get is an empty cmd with only "C:\"...

    i also tried running this line with a ProcessBuilder, but that didn't work as well.
    the .bat file has to be under C:\Program Files, so moving it under a folder without a space in its path is not an option.

    does anyone know how can i pass through this problem?

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice